Java Swing Look and Feel setLAF(final String lafName)

Here you can find the source of setLAF(final String lafName)

Description

Tries to set the specified Look and Feel.

License

Apache License

Parameter

Parameter Description
name name of the look and feel to be loaded

Return

true if the LAF was set successfully, false otherwise

Declaration

public static boolean setLAF(final String lafName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class Main {
    /**/*from   w w  w . j  a v a 2  s.  c  o  m*/
     * Tries to set the specified Look and Feel.
     * @param name name of the look and feel to be loaded
     * @return true if the LAF was set successfully, false otherwise
     */
    public static boolean setLAF(final String lafName) {
        for (final LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels())
            if (lookAndFeelInfo.getName().equals(lafName))
                try {
                    UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());

                    return true;
                } catch (final Exception e) {
                    System.err.println("Failed to set " + lookAndFeelInfo.getName() + " look and feel!");
                    e.printStackTrace(System.err);
                    return false;
                }

        System.err.println(lafName + " look and feel was not found!");

        return false;
    }
}

Related

  1. setDefaultLookandfeel()
  2. setJavaLookAndFeel()
  3. setJavaLookAndFeel()
  4. setJavaLookAndFeel()
  5. setLaf()
  6. setLAF(String className)
  7. setLaf(String lafName)
  8. setLAF(String LAFName)
  9. setLAFNimbus()