Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set a default font for entire application? 2

Status
Not open for further replies.

ModelTrains

Programmer
Nov 12, 2002
40
US
How do I set the default font for the entire application?
I currently have this:
Code:
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            Font f = new Font("Arial", Font.PLAIN, 12);
            UIManager.put("Menu.font", f);
            UIManager.put("MenuBar.font", f);
            UIManager.put("MenuItem.font", f);
            UIManager.put("Label.font", f);
            UIManager.put("Button.font", f);

THE PROBLEM:
I cannot find a list of objects that need to have the font set. How do I set the font in a JComboBox? I found out, using trial-and-error, that you set a JLabel using "Label.font". I need a list of other components/objects.

Thank you in advance for the list! (or reference to one.)
 
Something like this?
Code:
    java.util.Enumeration keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      Object value = UIManager.get(key);
      if (value instanceof javax.swing.plaf.FontUIResource) {
        UIManager.put(key, f);
      }
    }

Where 'f' is a reference to your Font.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top