Swing JButton does not change onclick background color

I want the button on the click to never change the background color, by default the color will change to cyan gray.

So this is my code

JButton b = new JButton();
b.setBackground(SystemColor.control);

I want the button to be pressed, it will never change the background color.

+3
source share
2 answers

Button painting depends on LAF. You can do one of the following:

  • Define your own user interface delegate and assign it to the button. Disadvantages : complex, interrupts LAF.
  • JButton paintComponent(). . .
  • , setContentAreaFilled(false), . : , LAF . : , , , .
+2

, . , , .

Nimbus, , - , . - , .

+1

Source: https://habr.com/ru/post/1753306/


All Articles