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:Good_GUi.java

/**
 * @param args the command line arguments
 *//*from ww w.j a va2s  . c o m*/

public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */

    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }
    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Good_GUi().setVisible(true);
        }
    });
}

From source file:musite.MusiteMain.java

private static void setupLookAndFeel() {
    try {//from   w  w  w.ja v  a2 s  . co m
        if (SystemUtils.IS_OS_WINDOWS) {
            /*
             * For Windows: just use platform default look & feel.
             */
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } else if (SystemUtils.IS_OS_MAC) {
            /*
             * For Mac: move menue bar to OS X default bar (next to Apple
             * icon)
             */
            System.setProperty("apple.laf.useScreenMenuBar", "true");
        } else {
            /*
             * For Unix platforms, use JGoodies Looks
             */
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            Plastic3DLookAndFeel.set3DEnabled(true);
            Plastic3DLookAndFeel.setCurrentTheme(new com.jgoodies.looks.plastic.theme.SkyBluer());
            Plastic3DLookAndFeel.setTabStyle(Plastic3DLookAndFeel.TAB_STYLE_METAL_VALUE);
            Plastic3DLookAndFeel.setHighContrastFocusColorsEnabled(true);

            Options.setDefaultIconSize(new Dimension(18, 18));
            Options.setHiResGrayFilterEnabled(true);
            Options.setPopupDropShadowEnabled(true);
            Options.setUseSystemFonts(true);

            UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
            UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LaunchDiagnosticTool.java

@Override
public void run(CommandLine commandLine) throws Exception {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//from   w  w w  .  j ava2 s .  c o  m
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                //silently handle
            }

            DiagnosticTool diagnosticTool = new DiagnosticTool();
            diagnosticTool.setIconImages(Settings.getIconImages());
            diagnosticTool.setVisible(true);
        }

    });
}

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

private void setNativeLookAndFeel() {
    try {//from w  ww .ja  v a  2  s  .co m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        GTKHelper.installGtkPopupBugWorkaround();
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:ui.Interface.java

public Interface() throws UnsupportedLookAndFeelException, ParseException {
    UIManager.setLookAndFeel(new SyntheticaSilverMoonLookAndFeel());
    initComponents();//from   w  w w  .  ja  v a 2  s. c om
    setResizable(false);
    Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
    Dimension windowSize = new Dimension(getPreferredSize());
    int wdwLeft = 50 + screenSize.width / 2 - windowSize.width / 2;
    int wdwTop = screenSize.height / 2 - windowSize.height / 2;
    pack();
    setLocation(wdwLeft, wdwTop);
    setTitle("Sorting Algo Simulator v2.0");
}

From source file:edu.uchc.octane.OctanePlugin.java

/**
 * Constructor/*from   w ww. j  a  va 2 s.co  m*/
 */
public OctanePlugin() {
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (Exception e) {

        System.err.println(e.getMessage());

    }
}

From source file:de.daibutsu.main.MainStart.java

public void run() {
    System.getProperties().setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName());
    try {//from   w  ww.  j  a  v  a 2 s . c  o  m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        throw new RuntimeException("Error!", e);
    }

    starteAnwendung();
}

From source file:Main.java

private void changeTheLookAndFeel(int value) {
    try {/*from  ww  w. j  av  a  2 s .c  o  m*/
        UIManager.setLookAndFeel(looks[value].getClassName());
        SwingUtilities.updateComponentTreeUI(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.uzk.hki.da.sb.SIPBuilder.java

/**
 * Starts the SIP-Builder in GUI mode/*from  w  w w .j  av a 2  s. co m*/
 * 
 * @param confFolderPath Path to conf folder
 * @param dataFolderPath Path to data folder
 */
private static void startGUIMode(String confFolderPath, String dataFolderPath) {

    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        return;
    }

    UIManager.put("Label.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("ComboBox.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("CheckBox.disabledText", Color.LIGHT_GRAY);

    Gui gui = new Gui(confFolderPath, dataFolderPath);
    gui.setBounds(100, 100, 750, 520);
    gui.setResizable(false);
    gui.setVisible(true);
    gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    gui.setTitle("DA NRW SIP-Builder");
}

From source file:jshm.gui.GuiUtil.java

/**
 * This sets the default L&F as well as sets some icons
 *///w ww. ja va2 s. co m
public static void init() {
    try {
        // Set the Look & Feel to match the current system
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    // http://www.java2s.com/Tutorial/Java/0240__Swing/CustomizingaJOptionPaneLookandFeel.htm
    UIManager.put("OptionPane.errorIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete.png")));
    UIManager.put("OptionPane.informationIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/infoabout.png")));
    UIManager.put("OptionPane.questionIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/help.png")));
    UIManager.put("OptionPane.warningIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/pause.png")));
    UIManager.put("OptionPane.yesIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/accept32.png")));
    UIManager.put("OptionPane.noIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete32.png")));

    float scale = Config.getFloat("font.scale");

    if (1f != scale) {
        LOG.finest("setting ui font scale to + " + scale);

        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);

            if (value instanceof FontUIResource) {
                FontUIResource f = (FontUIResource) value;
                f = new FontUIResource(f.deriveFont(scale * f.getSize2D()));
                UIManager.put(key, f);
            }
        }
    }

    // hook into the wizard displayer
    System.setProperty("WizardDisplayer.default", "jshm.gui.wizards.displayer.WizardDisplayerImpl");
}