Java Utililty Methods Swing Look and Feel

List of utility methods to do Swing Look and Feel

Description

The list of methods to do Swing Look and Feel are organized into topic(s).

Method

LookAndFeelgetSystemLAF()
get System LAF
if (SYSTEM_LAF == null) {
    try {
        SYSTEM_LAF = (LookAndFeel) Class.forName(UIManager.getSystemLookAndFeelClassName(), true,
                Thread.currentThread().getContextClassLoader()).newInstance();
        SYSTEM_LAF.initialize();
    } catch (Exception e) {
        throw new IllegalStateException("could not initialize " + UIManager.getSystemLookAndFeelClassName(),
                e);
...
voidinitLookAndFeel()
init Look And Feel
String key;
Object okey;
for (Enumeration e = UIManager.getLookAndFeelDefaults().keys(); e.hasMoreElements();) {
    okey = e.nextElement(); 
    key = okey.toString(); 
    if (key.endsWith(".font") || key.endsWith("Font")) {
        UIManager.put(okey, smallFont);
UIManager.put("ProgressBar.foreground", pastelBlue);
UIManager.put("ProgressBar.background", java.awt.Color.lightGray);
UIManager.put("Label.foreground", java.awt.Color.black);
voidinitLookAndFeel()
init Look And Feel
String key;
for (Enumeration e = UIManager.getLookAndFeelDefaults().keys(); e.hasMoreElements();) {
    key = (String) e.nextElement();
    if (key.endsWith(".font") || key.endsWith("Font")) {
        UIManager.put(key, smallFont);
UIManager.put("ProgressBar.foreground", pastelBlue);
...
voidinitLookAndFeel(final String className)
Initializes the look and feel and wraps exceptions into a runtime exception.
if (SwingUtilities.isEventDispatchThread()) {
    initLookAndFeelIntern(className);
} else {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                initLookAndFeelIntern(className);
        });
    } catch (final Exception ex) {
        throw new RuntimeException(ex);
voidinitLookAndFeelIntern(final String className)
Initializes the look and feel and wraps exceptions into a runtime exception.
try {
    UIManager.setLookAndFeel(className);
} catch (final Exception e) {
    throw new RuntimeException("Error initializing the Look And Feel!", e);
voidinstallLookAndFeel()
Look and feel, helper for Schedule#start() and HospitalityMembers#start() .
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < lafInfo.length; i++) {
    if (lafInfo[i].getName().equals("Windows")) {
        try {
            UIManager.setLookAndFeel(lafInfo[i].getClassName());
        } catch (ClassNotFoundException e) {
            e.printStackTrace(); 
        } catch (InstantiationException e) {
...
booleanisAqua()
Tests if the look and feel is Aqua or a derivative (e.g.
if (isQuaqua()) {
    return true;
Class<?> lafClass = UIManager.getLookAndFeel().getClass();
while (lafClass != null) {
    if ("com.apple.laf.AquaLookAndFeel".equals(lafClass.getName())) {
        return true;
    lafClass = lafClass.getSuperclass();
return false;
booleanisAquaLookAndFeel()
is Aqua Look And Feel
return UIManager.getLookAndFeel().getID().equals("Aqua");
booleanisAquaLookAndFeel()
MacOS Look and feel test
return System.getProperty("mrj.version") != null && UIManager.getSystemLookAndFeelClassName()
        .equals(UIManager.getLookAndFeel().getClass().getName());
booleanisAquaLookAndFeel()
Determines if current L&F is AquaLookAndFeel
return UIManager.getLookAndFeel().getID().equals("Aqua");