Example usage for javax.swing UIManager getInstalledLookAndFeels

List of usage examples for javax.swing UIManager getInstalledLookAndFeels

Introduction

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

Prototype

public static LookAndFeelInfo[] getInstalledLookAndFeels() 

Source Link

Document

Returns an array of LookAndFeelInfo s representing the LookAndFeel implementations currently available.

Usage

From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java

/**
 * Initialize the contents of the frame.
 *//*  w w  w .  j a v  a2 s .co  m*/
private void initialize() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
        // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    splitPane = new JSplitPane();
    frame.getContentPane().add(splitPane, BorderLayout.CENTER);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setPreferredSize(new Dimension(500, 7));
    splitPane.setRightComponent(tabbedPane);

    componentDetailsTab = new JScrollPane();
    tabbedPane.addTab("Component details", null, componentDetailsTab, null);

    componentEditor = new JEditorPane();
    componentDetailsTab.setViewportView(componentEditor);

    sourceTab = new JScrollPane();
    tabbedPane.addTab("Source", null, sourceTab, null);

    sourceEditor = createSourceEditor();
    sourceEditor.setEditable(false);
    sourceTab.setViewportView(sourceEditor);

    textLineNumber = createTextLineNumber();
    sourceTab.setRowHeaderView(textLineNumber);

    highlightingTab = new JScrollPane();
    tabbedPane.addTab("Highlighting", null, highlightingTab, null);

    highlightingEditor = new JEditorPane();
    highlightingTab.setViewportView(highlightingEditor);

    symbolTab = new JScrollPane();
    tabbedPane.addTab("Symbol references", null, symbolTab, null);

    symbolEditor = new JEditorPane();
    symbolTab.setViewportView(symbolEditor);

    coverageTab = new JScrollPane();
    tabbedPane.addTab("Coverage", null, coverageTab, null);

    coverageEditor = new JEditorPane();
    coverageTab.setViewportView(coverageEditor);

    duplicationTab = new JScrollPane();
    tabbedPane.addTab("Duplications", null, duplicationTab, null);

    duplicationEditor = new JEditorPane();
    duplicationTab.setViewportView(duplicationEditor);

    testsTab = new JScrollPane();
    tabbedPane.addTab("Tests", null, testsTab, null);

    testsEditor = new JEditorPane();
    testsTab.setViewportView(testsEditor);

    issuesTab = new JScrollPane();
    tabbedPane.addTab("Issues", null, issuesTab, null);

    issuesEditor = new JEditorPane();
    issuesTab.setViewportView(issuesEditor);

    measuresTab = new JScrollPane();
    tabbedPane.addTab("Measures", null, measuresTab, null);

    measuresEditor = new JEditorPane();
    measuresTab.setViewportView(measuresEditor);

    scmTab = new JScrollPane();
    tabbedPane.addTab("SCM", null, scmTab, null);

    scmEditor = new JEditorPane();
    scmTab.setViewportView(scmEditor);

    activeRuleTab = new JScrollPane();
    tabbedPane.addTab("ActiveRules", null, activeRuleTab, null);

    activeRuleEditor = new JEditorPane();
    activeRuleTab.setViewportView(activeRuleEditor);

    treeScrollPane = new JScrollPane();
    treeScrollPane.setPreferredSize(new Dimension(200, 400));
    splitPane.setLeftComponent(treeScrollPane);

    componentTree = new JTree();
    componentTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("empty") {
        {
        }
    }));
    treeScrollPane.setViewportView(componentTree);
    componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    componentTree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent();

            if (node == null) {
                // Nothing is selected.
                return;
            }

            frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            updateDetails((Component) node.getUserObject());
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

        }

    });
    frame.pack();
}

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

private static void setLookAndFeel() {
    try {/*from w  w  w  . j  a v  a 2s .c  om*/
        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.ut.biolab.medsavant.MedSavantClient.java

private static void setLAF() {
    try {/* w  w w  . j ava2  s .  c  o  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);
    }

}

From source file:org.yccheok.jstock.gui.JStock.java

public void createLookAndFeelMenuItems() {
    LookAndFeel currentlaf = UIManager.getLookAndFeel();

    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();

    for (int i = 0; i < lafInfo.length; i++) {
        JMenuItem mi = (JRadioButtonMenuItem) jMenu4.add(new JRadioButtonMenuItem(lafInfo[i].getName()));
        buttonGroup1.add(mi);//from   w w w  .j a va  2  s . c om
        mi.addActionListener(new ChangeLookAndFeelAction(this, lafInfo[i].getClassName()));

        if (currentlaf != null) {
            if (lafInfo[i].getClassName().equals(currentlaf.getClass().getName())) {
                ((JRadioButtonMenuItem) mi).setSelected(true);
            }
        }
    }

    // Always on Top
    jMenu4.addSeparator();
    this.alwaysOnTopMenuItem = jMenu4.add(new JCheckBoxMenuItem(GUIBundle.getString("MainFrame_AlwaysOnTop")));

    this.alwaysOnTopMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            AbstractButton aButton = (AbstractButton) e.getSource();
            boolean selected = aButton.getModel().isSelected();

            JStock.this._setAlwaysOnTop(selected);
        }
    });
}

From source file:org.yccheok.jstock.gui.MainFrame.java

public void createLookAndFeelMenuItem() {
    LookAndFeel currentlaf = UIManager.getLookAndFeel();

    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();

    for (int i = 0; i < lafInfo.length; i++) {
        JMenuItem mi = (JRadioButtonMenuItem) jMenu4.add(new JRadioButtonMenuItem(lafInfo[i].getName()));
        buttonGroup1.add(mi);//w  w w. j  a  va  2s.c  o m
        mi.addActionListener(new ChangeLookAndFeelAction(this, lafInfo[i].getClassName()));

        if (currentlaf != null) {
            if (lafInfo[i].getClassName().equals(currentlaf.getClass().getName())) {
                ((JRadioButtonMenuItem) mi).setSelected(true);
            }
        }
    }
}

From source file:org.zaproxy.zap.GuiBootstrap.java

/**
 * Setups Swing's look and feel./*from   w w  w. j  av a 2 s. c o  m*/
 */
private void setupLookAndFeel() {
    try {
        // Set the systems Look and Feel
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        if (Constant.isMacOsX()) {
            OsXGui.setup();
        } else {
            // Set Nimbus LaF if available
            for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        }
    } catch (final UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
            | IllegalAccessException e) {
        // handle exception
    }
}

From source file:org.zephyrsoft.sdb2.MainController.java

/**
 * Use a nice LaF./*ww w  . j  av a2s  . c  o m*/
 * 
 * @return {@code true} if the LaF could be applied, {@code false} otherwise
 */
public boolean setupLookAndFeel() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
        return true;
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        LOG.warn("could not apply the look-and-feel");
        return false;
    }
}

From source file:pcgen.gui2.plaf.LookAndFeelManager.java

private static LookAndFeelInfo getNimbusLaf() {
    LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    for (LookAndFeelInfo lookAndFeelInfo : lafInfo) {
        if ("nimbus".equalsIgnoreCase(lookAndFeelInfo.getName())) {
            return lookAndFeelInfo;
        }/*from ww w. j  ava 2 s  .  co m*/
    }
    return null;
}

From source file:tvbrowser.core.Settings.java

private static String getDefaultLookAndFeelClassName() {
    String lnf = UIManager.getSystemLookAndFeelClassName();
    if (StringUtils.containsIgnoreCase(lnf, "metal")) {
        LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
        if (lnfs != null) {
            for (LookAndFeelInfo lookAndFeel : lnfs) {
                if (StringUtils.containsIgnoreCase(lookAndFeel.getName(), "Nimbus")) {
                    lnf = lookAndFeel.getClassName();
                }/* w w  w . j  a  va 2  s . c  o m*/
            }
        }
    }
    return lnf;
}

From source file:tvbrowser.TVBrowser.java

private static boolean lookAndFeelExists(String lnf) {
    boolean foundLNF = false;
    for (LookAndFeelInfo lnfInfo : UIManager.getInstalledLookAndFeels()) {
        if (lnfInfo.getClassName().equals(lnf)) {
            foundLNF = true;/*from w w  w . jav a  2  s  .c o  m*/
            break;
        }
    }
    return foundLNF;
}