Posted by Rob Camick on October 9, 2008
The UIManager contains information about the default properties of each Swing component. This information is stored in the UIDefaults class in the form of key/value pairs. Each Look and Feel will have its own set of default properties. The UIManager can be used to make changes to these properties.
At times you may want to know what the default value of a property is for a specific component. You can use code like this to get the default font for a JTextField:
Font font = UIManager.getFont("TextField.font");
Other times you may want to change the default value of a property for a specific component. You can use code like this to change the default font for all JTextFields:
UIManager.put("TextField.font", new FontUIResource( yourFontHere ));
Of course not all properties of a component can be controlled through the UIManager, so the question is – what properties are managed by the UIManager? Well, as mentioned earlier, all the information is contained in the UIDefaults class. The UIManagerDefaults program will simply display this information in a nicely formatted way.
Note that not all Look and Feels (LAF) use the same properties, so this type of solution can be very LAF dependent.