Example usage for javax.swing UIManager setLookAndFeel

List of usage examples for javax.swing UIManager setLookAndFeel

Introduction

In this page you can find the example usage for javax.swing UIManager setLookAndFeel.

Prototype

@SuppressWarnings("deprecation")
public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, UnsupportedLookAndFeelException 

Source Link

Document

Loads the LookAndFeel specified by the given class name, using the current thread's context class loader, and passes it to setLookAndFeel(LookAndFeel) .

Usage

From source file:UIUtilities.java

/**
 * Set up the user interface.//w w w . jav  a2s.com
 */
public static void setupUI() {
    try {
        final String classname = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(classname);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final UIDefaults defaults = UIManager.getDefaults();

    defaults.put("PopupMenu.border", new BorderUIResource.EtchedBorderUIResource(EtchedBorder.RAISED,
            defaults.getColor("controlShadow"), defaults.getColor("controlLtHighlight")));

    final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black);
    final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control"));
    final BorderUIResource.CompoundBorderUIResource compBorder = new BorderUIResource.CompoundBorderUIResource(
            emptyborder, matteborder);
    final BorderUIResource.EmptyBorderUIResource emptyBorderUI = new BorderUIResource.EmptyBorderUIResource(0,
            0, 0, 0);
    defaults.put("SplitPane.border", emptyBorderUI);
    defaults.put("Table.scrollPaneBorder", emptyBorderUI);
    defaults.put("ComboBox.border", compBorder);
    defaults.put("TextField.border", compBorder);
    defaults.put("TextArea.border", compBorder);
    defaults.put("CheckBox.border", compBorder);
    defaults.put("ScrollPane.border", emptyBorderUI);

}

From source file:org.excalibur.fm.configuration.Main.java

private static void configureLookAndFeel() {
    try {/*from ww w . ja  v a2 s  .c  o  m*/
        UIManager.setLookAndFeel((LookAndFeel) new Mirror()
                .on("com.jgoodies.looks.plastic.Plastic3DLookAndFeel").invoke().constructor().withoutArgs());
    } catch (Throwable e) {
    }
}

From source file:cl.almejo.vsim.Main.java

private void setNimbusLookAndFeel() {
    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
            } catch (ClassNotFoundException e) {
                e.printStackTrace();/*from ww  w. j  a v  a2  s .  c o  m*/
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
            break;
        }
    }
}

From source file:Main.java

/**
 * Enables look and feel with specified name only if such LaF is available
 *
 * @param lafName look and feel name//w w w .  j av a  2 s . c o  m
 */
public static void enableLafIfAvailable(String lafName) {
    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if (lafName.equals(info.getName())) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            } catch (Exception e) {
                // ignore
            }
        }
    }
}

From source file:Main.java

/**
 * Prepares the theme. The theme can be overridden with the specified environment variable. The default is the
 * system look and feel.//  w  w  w .java2s  .  c o m
 *
 * @param overrideEnvVar
 *            The environment variable to check for override value. Specify null for don't use override variable
 * @throws Exception
 *             When setting the theme failed
 */

public static void prepareTheme(final String overrideEnvVar) throws Exception {
    final String sysThemeStr = overrideEnvVar == null ? null : System.getenv().get(overrideEnvVar);
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    if (sysThemeStr == null || Boolean.parseBoolean(sysThemeStr)) {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
}

From source file:org.astrojournal.AJMain.java

/**
 * Start AJMainGUI.//  w  w  w  . java 2s.com
 * 
 * @param generator
 *            The generator
 * @param config
 *            The configuration
 */
private static void startAJMainGUI(final Generator generator, final Configuration config) {
    // Note Nimbus does not seem to show the vertical scroll bar if there is
    // too much text..
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        log.error(ex, ex);
    }

    // enable anti-aliased text:
    System.setProperty("awt.useSystemAAFontSettings", "gasp");
    System.setProperty("swing.aatext", "true");
    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            new AJMainGUI(generator, config).setVisible(true);
        }
    });
}

From source file:nh.examples.springintegration.order.client.OrderClient.java

private static void setLnF() {
    try {//from ww  w.  jav a 2 s. com
        UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel");
        SubstanceLookAndFeel.setSkin("org.pushingpixels.substance.api.skin.OfficeBlue2007Skin");

    } catch (Exception e) {
        System.out.println("Substance Graphite failed to initialize");
    }

}

From source file:captor.app.CaptorGui.java

protected static void installLookAndFeel(Model model) {
    boolean useConfiguredLNF = false;
    UIManager.LookAndFeelInfo[] installed = UIManager.getInstalledLookAndFeels();

    try {//from   w w  w.j  a  v  a 2  s  . com

        for (LookAndFeelInfo lnf : installed) {
            String name = lnf.getClassName();
            if (name.equals(model.getConfig().getGuiConfig().getLookAndFeel())) {
                useConfiguredLNF = true;
                break;
            }
        }

        if (useConfiguredLNF) {
            try {
                UIManager.setLookAndFeel(model.getConfig().getGuiConfig().getLookAndFeel());
            } catch (Exception e) {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (Exception e) {
        System.out.println("Cannot install look and feel.");
    }
}

From source file:com.softidea.www.private_access.adminstrator.admin_index.java

/**
 * Creates new form admin_index//  w  w  w  .  jav a2s  . c  o m
 */
public admin_index() {
    initComponents();
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception ex) {
    }
    try {
        AWTUtilities.setWindowOpaque(this, false);
    } catch (Exception e) {
    }
    pro_lookandfeel.Set();

    JFreeChart lineChart = ChartFactory.createLineChart("Title", "Years", "Number of Schools", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);
    loadChart();

}

From source file:hr.fer.zemris.vhdllab.platform.support.OSBasedUIManagerConfigurer.java

@Override
protected void doInstallCustomDefaults() throws Exception {
    if (System.getProperty("os.name").equals("Linux")) {
        try {//from  w  w  w .j av a2 s  .  com
            installJGoodiesLooks();
        } catch (UnsupportedLookAndFeelException e) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            UIManager.put("swing.boldMetal", Boolean.FALSE);
        }
    } else {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
}