dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Intermediate
Jul 19, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Modify Swing's Default Values

A previous tip, "Get a Hold of Swing Defaults," shows how to obtain the default settings for Swing components. It is easy to change any default settings programmatically. For example, Swing scrollbars have a purplish thumb. In fact, if you get the default value for "ScrollBar.thumb", you'll notice that it has a default setting of:

 
javax.swing.plaf.ColorUIResource[r=153,g=153,b=204]

To change the purplish thumb to a light gray thumb, you should first obtain a reference to javax.swing.UIDefaults (com.sun.java.swing.UIManager for Swing 1.03 and below) as in:

 
javax.swing.UIDefaults uid = javax.swing.UIManager.getDefaults();

UIDefaults is an extension of ava.util.Hashtable class, so next you'll write:

 
uid.put("ScrollBar.thumb", java.awt.Color.lightGray);

Note that the changes to Swing's default settings will take effect prior to creation of Swing components by your code.

Behrouz Fallahi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date