There are many ways to solve this problem.
The most obvious way is to add a fraction to an existing color value, for example ...
int red = 128; float fraction = 0.25f;
Instead, you can apply a load factor to the color instead. We know that the maximum value for a color element is 255, so instead of trying to increase the color coefficient itself, you can increase the color element by a factor over the entire range of colors, for example
int red = 128; float fraction = 0.25f;
This basically increases the color element by a factor of 255 instead of ... sassy. Now we also need to take into account the fact that color should never exceed 255
This will allow you to make colors come closer to white, as bright and black, as dark ...

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class BrighterColor { public static void main(String[] args) { new BrighterColor(); } public BrighterColor() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TestPane extends JPanel { public TestPane() { } @Override public Dimension getPreferredSize() { return new Dimension(200, 200); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); Rectangle rec = new Rectangle(0, 0, getWidth(), getHeight() / 2); g2d.setColor(Color.BLUE); g2d.fill(rec); g2d.translate(0, getHeight() / 2); g2d.setColor(brighten(Color.BLUE, 0.25)); g2d.fill(rec); g2d.dispose(); } } public static Color brighten(Color color, double fraction) { int red = (int) Math.round(Math.min(255, color.getRed() + 255 * fraction)); int green = (int) Math.round(Math.min(255, color.getGreen() + 255 * fraction)); int blue = (int) Math.round(Math.min(255, color.getBlue() + 255 * fraction)); int alpha = color.getAlpha(); return new Color(red, green, blue, alpha); } }
source share