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:org.spoutcraft.launcher.entrypoint.SpoutcraftLauncher.java

private static void setLookAndFeel() {
    OperatingSystem os = OperatingSystem.getOperatingSystem();
    if (os.equals(OperatingSystem.OSX)) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Technic Launcher");
    }// w  w w .  j  ava2  s  . c om
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed to setup look and feel", e);
    }
}

From source file:org.spoutcraft.launcher.entrypoint.Start.java

private static void launch(String[] args) throws Exception {
    // Text for local build (not official build)
    if (SpoutcraftLauncher.getLauncherBuild().equals("0")) {
        SpoutcraftLauncher.main(args);//from   w ww  .j a va 2  s.c  om
        return;
    }
    // Test for exe relaunch
    SpoutcraftLauncher.setupLogger().info("Args: " + Arrays.toString(args));
    if (args.length > 0 && (args[0].equals("-Mover") || args[0].equals("-Launcher"))) {
        String[] argsCopy = new String[args.length - 1];
        for (int i = 1; i < args.length; i++) {
            argsCopy[i - 1] = args[i];
        }
        if (args[0].equals("-Mover")) {
            Mover.main(argsCopy, true);
        } else {
            SpoutcraftLauncher.main(argsCopy);
        }
        return;
    }

    migrateFolders();

    YAMLProcessor settings = SpoutcraftLauncher.setupSettings();
    if (settings == null) {
        throw new NullPointerException("The YAMLProcessor object was null for settings.");
    }
    Settings.setYAML(settings);

    int version = Integer.parseInt(SpoutcraftLauncher.getLauncherBuild());
    int latest = getLatestLauncherBuild();
    if (version < latest) {
        File codeSource = new File(Start.class.getProtectionDomain().getCodeSource().getLocation().getPath());
        File temp;
        if (codeSource.getName().endsWith(".exe")) {
            temp = new File(Utils.getWorkingDirectory(), "temp.exe");
        } else {
            temp = new File(Utils.getWorkingDirectory(), "temp.jar");
        }

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

        ProgressSplashScreen splash = new ProgressSplashScreen();
        Download download = new Download(RestAPI.getLauncherDownloadURL(Settings.getLauncherChannel(),
                !codeSource.getName().endsWith(".exe")), temp.getPath());
        download.setListener(new LauncherDownloadListener(splash));
        download.run();

        ProcessBuilder processBuilder = new ProcessBuilder();
        ArrayList<String> commands = new ArrayList<String>();
        if (!codeSource.getName().endsWith(".exe")) {
            if (OperatingSystem.getOS().isWindows()) {
                commands.add("javaw");
            } else {
                commands.add("java");
            }
            commands.add("-Xmx256m");
            commands.add("-cp");
            commands.add(temp.getAbsolutePath());
            commands.add(Mover.class.getName());
        } else {
            commands.add(temp.getAbsolutePath());
            commands.add("-Mover");
        }
        commands.add(codeSource.getAbsolutePath());
        commands.addAll(Arrays.asList(args));
        processBuilder.command(commands);

        try {
            processBuilder.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.exit(0);
    } else {
        SpoutcraftLauncher.main(args);
    }
}

From source file:org.spoutcraft.launcher.Main.java

@SuppressWarnings("restriction")
private static void setLookAndFeel() {
    if (Utils.getOperatingSystem() == Utils.OS.MAC_OS) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Spoutcraft");
    }/*w  ww  .j a va 2  s . c o m*/
    try {
        boolean laf = false;
        if (Utils.getOperatingSystem() == Utils.OS.WINDOWS) {
            // This bypasses the expensive reflection calls
            try {
                UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
                laf = true;
            } catch (Exception ignore) {
            }
        }

        if (!laf) {
            // Can't guess the laf for other os's as easily
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed to setup look and feel", e);
    }
}

From source file:org.swiftexplorer.SwiftExplorer.java

public static void main(String[] args) {
    if (isMacOsX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                Configuration.INSTANCE.getAppName());
        try {//ww w  .  ja v a2 s.co m
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            logger.error("Error occurred while initializing the UI", e);
        }
    }

    // required: http://docs.oracle.com/javafx/2/api/javafx/application/Platform.html#setImplicitExit(boolean)
    // Otherwise, we may get an exception if we attempt to re-open the web-browser login windows
    Platform.setImplicitExit(false);

    // load the settings
    String settingsFile = "swiftexplorer-settings.xml";
    if (!new File(settingsFile).exists())
        settingsFile = null;
    try {
        Configuration.INSTANCE.load(settingsFile);
    } catch (ConfigurationException e) {
        logger.error("Error occurred while initializing the configuration", e);
    }

    Locale locale = Locale.getDefault();
    HasLocalizationSettings localizationSettings = Configuration.INSTANCE.getLocalizationSettings();
    if (localizationSettings != null) {
        Locale.Builder builder = new Locale.Builder();
        LanguageCode lang = localizationSettings.getLanguage();
        RegionCode reg = localizationSettings.getRegion();
        builder.setLanguage(lang.toString());
        if (reg != null)
            builder.setRegion(reg.toString());
        else
            builder.setRegion("");
        locale = builder.build();
    }

    final HasLocalizedStrings localizedStrings = new LocalizedStringsImpl(locale);

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                openMainWindow(new MainPanel(Configuration.INSTANCE, localizedStrings));
            } catch (IOException e) {
                logger.error("Error occurred while opening the main window", e);
            }
        }
    });
}

From source file:org.syphr.mythtv.apps.previewer.Main.java

private static void setLookAndFeel() {
    try {//www.  ja  va2 s.  com
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                return;
            }
        }

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.thelq.stackexchange.dbimport.gui.GUI.java

public GUI(Controller passedController) {
    //Initialize logger
    logAppender = new GUILogAppender(this);

    //Set our Look&Feel
    try {// ww  w  . j a  va2  s  . c  o m
        if (SystemUtils.IS_OS_WINDOWS)
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        else
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Defaulting to Swing L&F due to exception", e);
    }

    this.controller = passedController;
    frame = new JFrame();
    frame.setTitle("Unified StackExchange Data Dump Importer v" + Controller.VERSION);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    //Setup menu
    JMenuBar menuBar = new JMenuBar();
    menuAdd = new JMenuItem("Add Folders/Archives");
    menuAdd.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menuAdd);
    frame.setJMenuBar(menuBar);

    //Primary panel
    FormLayout primaryLayout = new FormLayout("5dlu, pref:grow, 5dlu, 5dlu, pref",
            "pref, top:pref, pref, fill:140dlu:grow, pref, fill:80dlu");
    PanelBuilder primaryBuilder = new PanelBuilder(primaryLayout)
            .border(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    //DB Config panel
    primaryBuilder.addSeparator("Database Configuration", CC.xyw(1, 1, 2));
    FormLayout configLayout = new FormLayout("pref, 3dlu, pref:grow, 6dlu, pref",
            "pref, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow");
    configLayout.setHonorsVisibility(true);
    final PanelBuilder configBuilder = new PanelBuilder(configLayout);
    configBuilder.addLabel("Server", CC.xy(1, 2), dbType = new JComboBox<DatabaseOption>(), CC.xy(3, 2));
    configBuilder.add(dbAdvanced = new JCheckBox("Show advanced options"), CC.xy(5, 2));
    configBuilder.addLabel("JDBC Connection", CC.xy(1, 4), jdbcString = new JTextField(15), CC.xyw(3, 4, 3));
    configBuilder.addLabel("Username", CC.xy(1, 6), username = new JTextField(10), CC.xy(3, 6));
    configBuilder.addLabel("Password", CC.xy(1, 8), password = new JPasswordField(10), CC.xy(3, 8));
    configBuilder.add(importButton = new JButton("Import"), CC.xywh(5, 6, 1, 3));
    //Add hidden
    JLabel dialectLabel = new JLabel("Dialect");
    dialectLabel.setVisible(false);
    configBuilder.add(dialectLabel, CC.xy(1, 10), dialect = new JTextField(10), CC.xyw(3, 10, 3));
    dialect.setVisible(false);
    JLabel driverLabel = new JLabel("Driver");
    driverLabel.setVisible(false);
    configBuilder.add(driverLabel, CC.xy(1, 12), driver = new JTextField(10) {
        @Override
        public void setText(String text) {
            if (StringUtils.isBlank(text))
                log.debug("Text is blank", new RuntimeException("Text " + text + " is blank"));
            super.setText(text);
        }
    }, CC.xyw(3, 12, 3));
    driver.setVisible(false);
    primaryBuilder.add(configBuilder.getPanel(), CC.xy(2, 2));

    //Options
    primaryBuilder.addSeparator("Options", CC.xyw(4, 1, 2));
    FormLayout optionsLayout = new FormLayout("pref, 3dlu, pref:grow", "");
    DefaultFormBuilder optionsBuilder = new DefaultFormBuilder(optionsLayout);
    optionsBuilder.append(disableCreateTables = new JCheckBox("Disable Creating Tables"), 3);
    optionsBuilder.append("Global Table Prefix", globalTablePrefix = new JTextField(7));
    optionsBuilder.append("Threads", threads = new JSpinner());
    //Save a core for the database
    int numThreads = Runtime.getRuntime().availableProcessors();
    numThreads = (numThreads != 1) ? numThreads - 1 : numThreads;
    threads.setModel(new SpinnerNumberModel(numThreads, 1, 100, 1));
    optionsBuilder.append("Batch Size", batchSize = new JSpinner());
    batchSize.setModel(new SpinnerNumberModel(500, 1, 500000, 1));
    primaryBuilder.add(optionsBuilder.getPanel(), CC.xy(5, 2));

    //Locations
    primaryBuilder.addSeparator("Dump Locations", CC.xyw(1, 3, 5));
    FormLayout locationsLayout = new FormLayout("pref, 15dlu, pref, 5dlu, pref, 5dlu, pref:grow, 2dlu, pref",
            "");
    locationsBuilder = new DefaultFormBuilder(locationsLayout, new ScrollablePanel()).background(Color.WHITE)
            .lineGapSize(Sizes.ZERO);
    locationsPane = new JScrollPane(locationsBuilder.getPanel());
    locationsPane.getViewport().setBackground(Color.white);
    locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    primaryBuilder.add(locationsPane, CC.xyw(2, 4, 4));

    //Logger
    primaryBuilder.addSeparator("Log", CC.xyw(1, 5, 5));
    loggerText = new JTextPane();
    loggerText.setEditable(false);
    JPanel loggerTextPanel = new JPanel(new BorderLayout());
    loggerTextPanel.add(loggerText);
    JScrollPane loggerPane = new JScrollPane(loggerTextPanel);
    loggerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    loggerPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JPanel loggerPanePanel = new JPanel(new BorderLayout());
    loggerPanePanel.add(loggerPane);
    primaryBuilder.add(loggerPanePanel, CC.xyw(2, 6, 4));

    menuAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //TODO: Allow 7z files but handle corner cases
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fc.setMultiSelectionEnabled(true);
            fc.setDialogTitle("Select Folders/Archives");
            fc.addChoosableFileFilter(new FileNameExtensionFilter("Archives", "7z", "zip"));
            fc.addChoosableFileFilter(new FileFilter() {
                @Getter
                protected String description = "Folders";

                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }
            });

            if (fc.showOpenDialog(frame) != JFileChooser.APPROVE_OPTION)
                return;

            //Add files and folders in a seperate thread while updating gui in EDT
            importButton.setEnabled(false);
            for (File curFile : fc.getSelectedFiles()) {
                DumpContainer dumpContainer = null;
                try {
                    if (curFile.isDirectory())
                        dumpContainer = new FolderDumpContainer(curFile);
                    else
                        dumpContainer = new ArchiveDumpContainer(controller, curFile);
                    controller.addDumpContainer(dumpContainer);
                } catch (Exception ex) {
                    String type = (dumpContainer != null) ? dumpContainer.getType() : "";
                    LoggerFactory.getLogger(getClass()).error("Cannot open " + type, ex);
                    String location = (dumpContainer != null) ? Utils.getLongLocation(dumpContainer) : "";
                    showErrorDialog(ex, "Cannot open " + location, curFile.getAbsolutePath());
                    continue;
                }
            }
            updateLocations();
            importButton.setEnabled(true);
        }
    });

    //Add options (Could be in a map, but this is cleaner)
    dbType.addItem(new DatabaseOption().name("MySQL 5.5.3+")
            .jdbcString("jdbc:mysql://127.0.0.1:3306/stackexchange?rewriteBatchedStatements=true")
            .dialect("org.hibernate.dialect.MySQL5Dialect").driver("com.mysql.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.1")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL81Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.2+")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL82Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServerDialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2005+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2005Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2008+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2008Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("H2").jdbcString("jdbc:h2:stackexchange")
            .dialect("org.hibernate.dialect.H2Dialect").driver("org.h2.Driver"));
    dbType.setSelectedItem(null);
    dbType.addItemListener(new ItemListener() {
        boolean shownMysqlWarning = false;

        public void itemStateChanged(ItemEvent e) {
            //Don't run this twice for a single select
            if (e.getStateChange() == ItemEvent.DESELECTED)
                return;

            DatabaseOption selectedOption = (DatabaseOption) dbType.getSelectedItem();
            if (selectedOption.name().startsWith("MySQL") && !shownMysqlWarning) {
                //Hide popup so you don't have to click twice on the dialog 
                dbType.setPopupVisible(false);
                JOptionPane.showMessageDialog(frame,
                        "Warning: Your server must be configured with character_set_server=utf8mb4"
                                + "\nOtherwise, data dumps that contain 4 byte UTF-8 characters will fail",
                        "MySQL Warning", JOptionPane.WARNING_MESSAGE);
                shownMysqlWarning = true;
            }

            setDbOption(selectedOption);
        }
    });

    //Show and hide advanced options with checkbox
    dbAdvanced.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean selected = ((JCheckBox) e.getSource()).isSelected();
            driver.setVisible(selected);
            ((JLabel) driver.getClientProperty("labeledBy")).setVisible(selected);
            dialect.setVisible(selected);
            ((JLabel) dialect.getClientProperty("labeledBy")).setVisible(selected);
        }
    });

    importButton.addActionListener(new ActionListener() {
        protected void showImportError(String error) {
            JOptionPane.showMessageDialog(frame, error, "Configuration Error", JOptionPane.ERROR_MESSAGE);
        }

        protected void showInputErrorDatabase(String error) {
            if (dbType.getSelectedItem() == null)
                showImportError("No dbType specified, " + StringUtils.uncapitalize(error));
            else
                showImportError(error);
        }

        public void actionPerformed(ActionEvent e) {
            boolean validationPassed = false;
            if (controller.getDumpContainers().isEmpty())
                showImportError("Please add dump folders/archives");
            else if (StringUtils.isBlank(jdbcString.getText()))
                showInputErrorDatabase("Must specify JDBC String");
            else if (StringUtils.isBlank(driver.getText()))
                showInputErrorDatabase("Must specify driver");
            else if (StringUtils.isBlank(dialect.getText()))
                showInputErrorDatabase("Must specify hibernate dialect");
            else
                validationPassed = true;

            if (!validationPassed)
                return;

            //Disable all GUI components so they can't change anything during processing
            setGuiEnabled(false);

            //Run in new thread
            controller.getGeneralThreadPool().execute(new Runnable() {
                public void run() {
                    try {
                        start();
                    } catch (final Exception e) {
                        //Show an error message box
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                LoggerFactory.getLogger(getClass()).error("Cannot import", e);
                                showErrorDialog(e, "Cannot import", null);
                            }
                        });
                    }
                    //Renable GUI
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            setGuiEnabled(true);
                        }
                    });
                }
            });
        }
    });

    //Done, init logger
    logAppender.init();
    log.info("Finished creating GUI");

    //Display
    frame.setContentPane(primaryBuilder.getPanel());
    frame.pack();
    frame.setMinimumSize(frame.getSize());

    frame.setVisible(true);
}

From source file:org.tinymediamanager.ui.components.JNativeFileChooser.java

@Override
public void updateUI() {
    if (SystemUtils.IS_OS_WINDOWS) {
        // on windows set the native laf
        LookAndFeel old = UIManager.getLookAndFeel();
        try {/*from w  w w  .j a  v a 2s  . co m*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Throwable ex) {
            old = null;
        }

        super.updateUI();

        if (old != null) {
            try {
                UIManager.setLookAndFeel(old);
            } catch (Exception ignored) {
            } // shouldn't get here
        }
    } else {
        // on linux/mac as is
        super.updateUI();
    }
}

From source file:org.trianacode.gui.hci.ApplicationFrame.java

/**
 * Initialise the application//from  w ww. j a v a2 s  . c  o m
 */
public static ApplicationFrame initTriana(String args[]) {
    // todo: this is crap, use andrew's UI stuff
    // Andrew Sept 2010: Done - 6 years on... :-)
    UIDefaults uiDefaults = UIManager.getDefaults();
    Object font = ((FontUIResource) uiDefaults.get("TextArea.font")).deriveFont((float) 11);

    Enumeration enumeration = uiDefaults.keys();
    while (enumeration.hasMoreElements()) {
        Object key = enumeration.nextElement();

        if (key.toString().endsWith("font")) {
            uiDefaults.put(key, font);
        }
    }

    String myOSName = Locations.os();
    if (myOSName.equals("windows")) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
        }
    } else {
        if (!myOSName.equals("osx")) {
            try {
                MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
            }
        }

    }

    ApplicationFrame app = new ApplicationFrame("Triana");
    app.init(args);

    return app;
}

From source file:org.tros.torgo.Main.java

/**
 * Entry Point/*  w ww.j  a v a  2  s. c  om*/
 *
 * @param args
 */
public static void main(String[] args) {
    //initialize the logging
    splashInit();
    org.tros.utils.logging.Logging.initLogging(TorgoInfo.INSTANCE);
    Options options = new Options();
    options.addOption("l", "lang", true, "Open using the desired language. [default is 'logo']");
    options.addOption("i", "list", false, "List available languages.");
    String lang = "dynamic-logo";
    try {
        CommandLineParser parser = new org.apache.commons.cli.DefaultParser();
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("lang") || cmd.hasOption("l")) {
            lang = cmd.getOptionValue("lang");
        } else if (cmd.hasOption("i") || cmd.hasOption("list")) {
            Set<String> toolkits = TorgoToolkit.getToolkits();
            for (String name : toolkits) {
                System.out.println(name);
            }
            //will force an exit
            lang = null;
        }
    } catch (ParseException ex) {
        org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class).fatal(null, ex);
    }

    //currently commented out for working with snapd
    if (System.getProperty("swing.defaultlaf") == null) {
        try {
            //set look and feel (laf) to that of the system.
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException ex) {
            org.tros.utils.logging.Logging.getLogFactory().getLogger(Main.class).fatal(null, ex);
        }
    }

    final String controlLang = lang;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Controller controller = TorgoToolkit.getController(controlLang);
            if (controller != null) {
                controller.run();
            }
        }
    });
}

From source file:org.ut.biolab.medsavant.MedSavantClient.java

private static void setLAF() {
    try {//from  w  w  w.j a v  a  2s .  co m

        if (ClientMiscUtils.MAC) {
            customizeForMac();
        }

        // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); //Metal works with sliders.
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); //GTK doesn't work with sliders.
        //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); //Nimbus doesn't work with sliders.
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            LOG.debug("Installed LAF: " + info.getName() + " class: " + info.getClassName());
        }
        LOG.debug("System LAF is: " + UIManager.getSystemLookAndFeelClassName());
        LOG.debug("Cross platform LAF is: " + UIManager.getCrossPlatformLookAndFeelClassName());

        LookAndFeelFactory.addUIDefaultsInitializer(new LookAndFeelFactory.UIDefaultsInitializer() {
            public void initialize(UIDefaults defaults) {
                Map<String, Object> defaultValues = new HashMap<String, Object>();
                defaultValues.put("Slider.trackWidth", new Integer(7));
                defaultValues.put("Slider.majorTickLength", new Integer(6));
                defaultValues.put("Slider.highlight", new ColorUIResource(255, 255, 255));
                defaultValues.put("Slider.horizontalThumbIcon",
                        javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon());
                defaultValues.put("Slider.verticalThumbIcon",
                        javax.swing.plaf.metal.MetalIconFactory.getVerticalSliderThumbIcon());
                defaultValues.put("Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0));

                for (Map.Entry<String, Object> e : defaultValues.entrySet()) {
                    if (defaults.get(e.getKey()) == null) {
                        LOG.debug("Missing key " + e.getKey() + ", using default value " + e.getValue());
                        defaults.put(e.getKey(), e.getValue());
                    } else {
                        LOG.debug("Found key " + e.getKey() + " with value " + defaults.get(e.getKey()));
                    }
                }
            }
        });

        if (MiscUtils.WINDOWS) {
            UIManager.put("CheckBox.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("Panel.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE_WITHOUT_MENU);
            /*UIManager.put("JideTabbedPane.tabAreaBackground", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("JideTabbedPane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("SidePane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));*/
        } else {
            LookAndFeelFactory.installJideExtension();
        }

        LookAndFeelFactory.installDefaultLookAndFeelAndExtension();

        System.setProperty("awt.useSystemAAFontSettings", "on");
        System.setProperty("swing.aatext", "true");

        UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));

        //tooltips
        UIManager.put("ToolTip.background", new ColorUIResource(255, 255, 255));
        ToolTipManager.sharedInstance().setDismissDelay(8000);
        ToolTipManager.sharedInstance().setInitialDelay(500);
    } catch (Exception x) {
        LOG.error("Unable to install look & feel.", x);
    }

}