• Post Reply Bookmark Topic Watch Topic
  • New Topic

Set color of all Swing components in one step?

 
Matt Wil
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Serghei Jelauc
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!