Is there any way to apply a color to all Swing components rather than doing it one at a time for every panel and button I have?
posted 12 years ago
Yes it is. There are two classes UIManager and UIDefaults in javax.swing package. You can access instance of UIDefaults by UIManager.getDefaults(). UIDefaults extends Hashtable and store objects in key-value structure. You can see all keys by using
Now if you want for example in your application all buttons have cyan color, you can do following: There is a key in UIDefaults Button.background and you have to set the Color object which corresponds to this key in cyan value.
So on. Now all buttons in your application will have blue color. Hope it halps. [ April 18, 2004: Message edited by: Serghei Jelauc ]