Java Utililty Methods Swing UIManager

List of utility methods to do Swing UIManager

Description

The list of methods to do Swing UIManager are organized into topic(s).

Method

voidprintDefaults()
Convenience method to print all the UI settings to System.out.
UIDefaults defaults = UIManager.getDefaults();
Enumeration<Object> keys = defaults.keys();
while (keys.hasMoreElements()) {
    Object key = keys.nextElement();
    System.out.println(key + ": " + defaults.get(key));
voidprintUIDefaults()
print UI Defaults
UIDefaults uiDefaults = UIManager.getDefaults();
Enumeration<Object> e = uiDefaults.keys();
while (e.hasMoreElements()) {
    Object key = e.nextElement();
    Object val = uiDefaults.get(key);
    System.out.println("[" + key.toString() + "]:[" + (null != val ? val.toString() : "(null)") + "]");
booleansetComponentLF(JComponent comp, String ui)
set Component LF
LookAndFeel previousLF = UIManager.getLookAndFeel();
try {
    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if (ui.equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
    comp.updateUI();
    UIManager.setLookAndFeel(previousLF);
} catch (Exception e) {
    return false;
return true;
voidsetCrossPlatformProperties()
set Cross Platform Properties
if (System.getProperty("os.name").startsWith("Mac")) {
    System.setProperty("apple.laf.useScreenMenuBar", "true");
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
voidsetDefaultSize(int size)
set Default Size
Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet();
Object[] keys = keySet.toArray(new Object[keySet.size()]);
for (Object key : keys) {
    if (key != null && key.toString().toLowerCase().contains("font")) {
        System.out.println(key);
        Font font = UIManager.getDefaults().getFont(key);
        if (font != null) {
            font = font.deriveFont((float) size);
...
voidsetEnabled(Component component, boolean enabled, boolean recursively)
set Enabled
component.setEnabled(enabled);
if (component instanceof JLabel) {
    Color color = enabled ? getLabelForeground() : getLabelDisabledForeground();
    if (color != null) {
        component.setForeground(color);
if (recursively && enabled == component.isEnabled()) {
...
voidsetNative()
Sets the default LAF.
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
booleanSetNetBeansCompatibleUIManager()
Set the application look-and-feel to match NetBeans.
UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
int lafno = 3; 
try {
    UIManager.setLookAndFeel(info[lafno].getClassName());
} catch (Exception e) {
    System.err.println("Couldn't load " + info[lafno].getClassName() + " look and feel " + e);
    return false;
return true;
booleansetNimbusLF()
Sets look and feel to Nimbus.
try {
    for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(laf.getName())) {
            UIManager.setLookAndFeel(laf.getClassName());
            break;
} catch (Exception e) {
...
voidsetSwingProperties(String appName)
set Swing Properties
UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder());
System.setProperty("com.apple.mrj.application.apple.menu.about.name", appName);
System.setProperty("apple.laf.useScreenMenuBar", "true");