You can change the color of individual buttons by doing a
JButton.setBackground(Color)
in the actionPerformed() method of the button's action listener.
For example, this code is a JButton that is one of two colors, depending on various conditions:
Originally posted by Ana Mihailescu:
Hi,
I have the following problem:
I have more JButtons and I want them to have a different color when are pressed. For this, I do
UIManager.put("Button.select",java.awt.Color.red);
buton1.updateUI();
and it works if I want the same color for all the buttons.
But if I try to change the color and to make updateUI() for a second button, it changes also the color for the first button.
So, what can I do if I want to have different colors for differnt buttons whent they are selected ?
Thank you,
Ana