Example usage for javax.swing UIManager getSystemLookAndFeelClassName

List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName

Introduction

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

Prototype

public static String getSystemLookAndFeelClassName() 

Source Link

Document

Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.

Usage

From source file:Main.java

/**
 * Set the look and feel of the specified component to the style of the
 * current system.//  www .  j a  v  a 2 s  .c  om
 * 
 * @param c
 *            the specified component
 */
public static void setSystemLookAndFeel(Component c) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        SwingUtilities.updateComponentTreeUI(c);
        c.validate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:codeswarm.ui.MainView.java

/**
 * This is the main entry-point. It sets the native Look&Feel, creates and
 * shows the MainView.//  w w  w  .  j  a  va2  s .c o  m
 * @param args the command line arguments. The first parameter
 * will be passed to {@link code_swarm}. It specifies the config-file.
 */
public static void main(final String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            Toolkit.getDefaultToolkit().setDynamicLayout(true);
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                logger.warn("Trouble loading system look and feel. No biggie...", e);
            }

            new MainView(args).setVisible(true);
        }
    });
}

From source file:com.clank.launcher.Launcher.java

/**
 * Bootstrap./*from   w w  w. ja  v a  2s  .c om*/
 *
 * @param args args
 */
public static void main(String[] args) {
    SimpleLogFormatter.configureGlobalLogger();

    LauncherArguments options = new LauncherArguments();
    try {
        new JCommander(options, args);
    } catch (ParameterException e) {
        System.err.print(e.getMessage());
        System.exit(1);
        return;
    }

    Integer bsVersion = options.getBootstrapVersion();
    log.info(bsVersion != null ? "Bootstrap version " + bsVersion + " detected" : "Not bootstrapped");

    File dir = options.getDir();
    if (dir != null) {
        log.info("Using given base directory " + dir.getAbsolutePath());
    } else {
        dir = new File(".");
        log.info("Using current directory " + dir.getAbsolutePath());
    }

    final File baseDir = dir;

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder());
                Launcher launcher = new Launcher(baseDir);
                new LauncherFrame(launcher).setVisible(true);
            } catch (Throwable t) {
                log.log(Level.WARNING, "Load failure", t);
                SwingHelper.showErrorDialog(null,
                        "Uh oh! The updater couldn't be opened because a " + "problem was encountered.",
                        "Launcher error", t);
            }
        }
    });

}

From source file:Main.java

static void setSwingLAF(java.awt.Component comp, String targetTheme) {

    try {// w w  w . j a  va  2  s . co  m
        if (targetTheme.equalsIgnoreCase(Native)) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else if (targetTheme.equalsIgnoreCase(Java)) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } else if (targetTheme.equalsIgnoreCase(Motif)) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        }

        //            if (targetTheme.equalsIgnoreCase(plaf)){
        //                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        //            }
        //
        //            if (targetTheme.equalsIgnoreCase(GTK)){
        //                UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        //            }
        SwingUtilities.updateComponentTreeUI(comp);

        if (comp instanceof java.awt.Frame) {
            ((java.awt.Frame) comp).pack();
        }
    } catch (Exception e) {
        errorMessage(e);
    }
}

From source file:Main.java

public static void setLookAndFeel() {
    if (UIManager.getLookAndFeel().getID().equals("Aqua")) { //$NON-NLS-1$
        SPINNERHEIGHT = 20;//from w w  w  .jav a 2  s .co m
    } else { // try to use Nimbus unless on Mac Os
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); //$NON-NLS-1$
        } catch (Exception e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
            } catch (InstantiationException e1) {
                e1.printStackTrace();
            } catch (IllegalAccessException e1) {
                e1.printStackTrace();
            } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
            }
        }
    }
}

From source file:com._17od.upm.gui.MainWindow.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                // Use the System look and feel
                Preferences.load();
                Translator.initialise();
                Double jvmVersion = new Double(System.getProperty("java.specification.version"));
                if (jvmVersion.doubleValue() < 1.4) {
                    JOptionPane.showMessageDialog(null, Translator.translate("requireJava14"),
                            Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
                    System.exit(1);
                } else {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    AppWindow = new MainWindow(applicationName);
                }/*from   w  w w. j av a2  s. c o m*/

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:Main.java

/**
 * Sets the system look and feel.//from  w  w  w .j a va 2 s .c  o  m
 * If this is not possible, this returns false. 
 * Otherwise, this sets the system look and feel and returns true.
 */
public static boolean setSystemLAF() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
        return false;
    } catch (InstantiationException e) {
        return false;
    } catch (IllegalAccessException e) {
        return false;
    } catch (UnsupportedLookAndFeelException e) {
        return false;
    }
    return true;
}

From source file:Main.java

/**
 * Try to set the default look and feel.
 *///w  w w. j a  va  2  s .c om
public static void setLookAndFeel() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
}

From source file:net.erdfelt.android.sdkfido.ui.utils.UIUtils.java

public static void setDefaultLookAndFeel() {
    try {/*from w  ww .ja v  a 2s.  c  o  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Unable to set System Look and Feel.", e);
    }

    JFrame.setDefaultLookAndFeelDecorated(true);
}

From source file:Main.java

/**
 * Tries to set the LookAndFeel to the os default
 * /*from w  w w  . ja  va  2s  . c o m*/
 * @return if the system look and feel could be set
 */
public static boolean setSystemLookAndFeel() {
    boolean isSystemLookAndFeelSet = true;
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        isSystemLookAndFeelSet = false;
    }
    return isSystemLookAndFeelSet;
}