This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes selection color for buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "selection color for buttons" Watch "selection color for buttons" New topic
Author

selection color for buttons

Ana Mihailescu
Greenhorn

Joined: Apr 26, 2001
Posts: 29
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
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
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


There's nothing more dangerous than a resourceful idiot. ---Dilbert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selection color for buttons
 
Similar Threads
update font of labels , menus and buttons
jButton revalidate, updateUI, repaint does not working
Passing value with two buttons
how to change color of a date in calendar
form submit