How to make a color darker in Java
10,799
You can do:
Color.ORANGE.darker()
or
Color.orange.darker()
Also, if you still think that it is not dark enough, you can even do:
Color.orange.darker().darker().darker().darker().darker() // as many times as you want!
Also, the default orange color, as defined in the class is:
new Color(255, 200, 0)
If you want, you may do something with those numbers!
In your code, change this line:
g2.setPaint(Color.orange.darker);
to
g2.setPaint(Color.orange.darker()); // darker ain't a var, it is a method.
And,
drawArea.orange.darker();
to
drawArea.orange(); //You cannot call darker() on void!
Author by
MrColdfish
Updated on June 04, 2022Comments
-
MrColdfish about 2 years
I am making a drawing tool in java, but the orange is seems a bit too light. Where to put the color name at the function
public Color darker()
?public void clear() { g2.setPaint(Color.white); // draw white on entire draw area to clear g2.fillRect(0, 0, getSize().width, getSize().height); g2.setPaint(Color.black); repaint(); } public void red() { // apply red color on g2 context g2.setPaint(Color.red); } public void black() { g2.setPaint(Color.black); } public void magenta() { g2.setPaint(Color.magenta); } public void green() { g2.setPaint(Color.green); } public void blue() { g2.setPaint(Color.blue); } public void yellow() { g2.setPaint(Color.yellow); } public void orange() { g2.setPaint(Color.orange.darker); } }
Please tell me what to write to make the orange darker.