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:edu.ku.brc.specify.utilapps.CreateTextSchema.java

/**
 * @param args/*  w  w  w  . java2  s  .c om*/
 */
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @SuppressWarnings("synthetic-access") //$NON-NLS-1$
        public void run() {
            try {
                UIHelper.OSTYPE osType = UIHelper.getOSType();
                if (osType == UIHelper.OSTYPE.Windows) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                } else if (osType == UIHelper.OSTYPE.Linux) {
                    UIManager.setLookAndFeel(new PlasticLookAndFeel());
                }
            } catch (Exception e) {
            }

            String schemaVersion = JOptionPane.showInputDialog("Enter Schema Version:");

            Locale.setDefault(currLang);

            try {
                ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

            } catch (MissingResourceException ex) {
                Locale.setDefault(Locale.ENGLISH);
                UIRegistry.setResourceLocale(Locale.ENGLISH);
            }

            CreateTextSchema cts = new CreateTextSchema();
            cts.process(schemaVersion);

            //File file = XMLHelper.getConfigDir(specifyDescFileName);
            //file.delete();

            JOptionPane.showMessageDialog(null, "Done");
        }
    });
}

From source file:net.sf.housekeeper.swing.ApplicationPresenter.java

/**
 * Initializes the Look and Feel.//from w  ww  .j a  v  a2s  . c  om
 */
private void initLookAndFeel() {

    if (SystemUtils.IS_OS_MAC_OSX) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    } else {
        try {
            UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    }

    LOG.debug("Using Look and Feel: " + UIManager.getLookAndFeel().getName());
}

From source file:imageviewer.system.ImageViewerClient.java

private void initialize(CommandLine args) {

    // First, process all the different command line arguments that we
    // need to override and/or send onwards for initialization.

    boolean fullScreen = (args.hasOption("fullscreen")) ? true : false;
    String dir = (args.hasOption("dir")) ? args.getOptionValue("dir") : null;
    String type = (args.hasOption("type")) ? args.getOptionValue("type") : "DICOM";
    String prefix = (args.hasOption("client")) ? args.getOptionValue("client") : null;

    LOG.info("Java home environment: " + System.getProperty("java.home"));

    // Logging system taken care of through properties file.  Check
    // for JAI.  Set up JAI accordingly with the size of the cache
    // tile and to recycle cached tiles as needed.

    verifyJAI();//from w w w  . j  a va2 s  .  c  o  m
    TileCache tc = JAI.getDefaultInstance().getTileCache();
    tc.setMemoryCapacity(32 * 1024 * 1024);
    TileScheduler ts = JAI.createTileScheduler();
    ts.setPriority(Thread.MAX_PRIORITY);
    JAI.getDefaultInstance().setTileScheduler(ts);
    JAI.getDefaultInstance().setRenderingHint(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, Boolean.TRUE);

    // Set up the frame and everything else.  First, try and set the
    // UI manager to use our look and feel because it's groovy and
    // lets us control the GUI components much better.

    try {
        UIManager.setLookAndFeel(new ImageViewerLookAndFeel());
        LookAndFeelAddons.setAddon(ImageViewerLookAndFeelAddons.class);
    } catch (Exception exc) {
        LOG.error("Could not set imageViewer L&F.");
    }

    // Load up the ApplicationContext information...

    ApplicationContext ac = ApplicationContext.getContext();
    if (ac == null) {
        LOG.error("Could not load configuration, exiting.");
        System.exit(1);
    }

    // Override the client node information based on command line
    // arguments...Make sure that the files are there, otherwise just
    // default to a local configuration.

    String hostname = new String("localhost");
    try {
        hostname = InetAddress.getLocalHost().getHostName();
    } catch (Exception exc) {
    }

    String[] gatewayConfigs = (prefix != null)
            ? (new String[] { "resources/server/" + prefix + "GatewayConfig.xml",
                    (String) ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG),
                    "resources/server/" + hostname + "GatewayConfig.xml",
                    "resources/server/localGatewayConfig.xml" })
            : (new String[] { (String) ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG),
                    "resources/server/" + hostname + "GatewayConfig.xml",
                    "resources/server/localGatewayConfig.xml" });
    String[] nodeConfigs = (prefix != null)
            ? (new String[] { "resources/server/" + prefix + "NodeConfig.xml",
                    (String) ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE),
                    "resources/server/" + hostname + "NodeConfig.xml", "resources/server/localNodeConfig.xml" })
            : (new String[] { (String) ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE),
                    "resources/server/" + hostname + "NodeConfig.xml",
                    "resources/server/localNodeConfig.xml" });

    for (int loop = 0; loop < gatewayConfigs.length; loop++) {
        String s = gatewayConfigs[loop];
        if ((s != null) && (s.length() != 0) && (!"null".equals(s))) {
            File f = new File(s);
            if (f.exists()) {
                ac.setProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG, s);
                break;
            }
        }
    }

    LOG.info("Using gateway config: " + ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG));

    for (int loop = 0; loop < nodeConfigs.length; loop++) {
        String s = nodeConfigs[loop];
        if ((s != null) && (s.length() != 0) && (!"null".equals(s))) {
            File f = new File(s);
            if (f.exists()) {
                ac.setProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE, s);
                break;
            }
        }
    }
    LOG.info("Using client config: " + ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE));

    // Load the layouts and set the default window/level manager...

    LayoutFactory.initialize();
    DefaultWindowLevelManager dwlm = new DefaultWindowLevelManager();

    // Create the main JFrame, set its behavior, and let the
    // ApplicationPanel know the glassPane and layeredPane.  Set the
    // menubar based on reading in the configuration menus.

    mainFrame = new JFrame("imageviewer");
    try {
        ArrayList<Image> iconList = new ArrayList<Image>();
        iconList.add(ImageIO.read(new File("resources/icons/mii.png")));
        iconList.add(ImageIO.read(new File("resources/icons/mii32.png")));
        mainFrame.setIconImages(iconList);
    } catch (Exception exc) {
    }

    mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    mainFrame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            int confirm = ApplicationPanel.getInstance().showDialog(
                    "Are you sure you want to quit imageViewer?", null, JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, UIManager.getIcon("Dialog.shutdownIcon"));
            if (confirm == JOptionPane.OK_OPTION) {
                boolean hasUnsaved = SaveStack.getInstance().hasUnsavedItems();
                if (hasUnsaved) {
                    int saveResult = ApplicationPanel.getInstance().showDialog(
                            "There is still unsaved data.  Do you want to save this data in the local archive?",
                            null, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION);
                    if (saveResult == JOptionPane.CANCEL_OPTION)
                        return;
                    if (saveResult == JOptionPane.YES_OPTION)
                        SaveStack.getInstance().saveAll();
                }
                LOG.info("Shutting down imageServer local archive...");
                try {
                    ImageViewerClientNode.getInstance().shutdown();
                } catch (Exception exc) {
                    LOG.error("Problem shutting down imageServer local archive...");
                } finally {
                    System.exit(0);
                }
            }
        }
    });

    String menuFile = (String) ApplicationContext.getContext().getProperty(ac.CONFIG_MENUS);
    String ribbonFile = (String) ApplicationContext.getContext().getProperty(ac.CONFIG_RIBBON);
    if (menuFile != null) {
        JMenuBar mb = new JMenuBar();
        mb.setBackground(Color.black);
        MenuReader.parseFile(menuFile, mb);
        mainFrame.setJMenuBar(mb);
        ApplicationContext.getContext().setApplicationMenuBar(mb);
    } else if (ribbonFile != null) {
        RibbonReader rr = new RibbonReader();
        JRibbon jr = rr.parseFile(ribbonFile);
        mainFrame.getContentPane().add(jr, BorderLayout.NORTH);
        ApplicationContext.getContext().setApplicationRibbon(jr);
    }
    mainFrame.getContentPane().add(ApplicationPanel.getInstance(), BorderLayout.CENTER);
    ApplicationPanel.getInstance().setGlassPane((JPanel) (mainFrame.getGlassPane()));
    ApplicationPanel.getInstance().setLayeredPane(mainFrame.getLayeredPane());

    // Load specified plugins...has to occur after the menus are
    // created, btw.

    PluginLoader.initialize("config/plugins.xml");

    // Detect operating system...

    String osName = System.getProperty("os.name");
    ApplicationContext.getContext().setProperty(ApplicationContext.OS_NAME, osName);
    LOG.info("Detected operating system: " + osName);

    // Try and hack the searched library paths if it's windows so we
    // can add a local dll path...

    try {
        if (osName.contains("Windows")) {
            Field f = ClassLoader.class.getDeclaredField("usr_paths");
            f.setAccessible(true);
            String[] paths = (String[]) f.get(null);
            String[] tmp = new String[paths.length + 1];
            System.arraycopy(paths, 0, tmp, 0, paths.length);
            File currentPath = new File(".");
            tmp[paths.length] = currentPath.getCanonicalPath() + "/lib/dll/";
            f.set(null, tmp);
            f.setAccessible(false);
        }
    } catch (Exception exc) {
        LOG.error("Error attempting to dynamically set library paths.");
    }

    // Get screen resolution...

    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    LOG.info("Detected screen resolution: " + (int) r.getWidth() + "x" + (int) r.getHeight());

    // Try and see if Java3D is installed, and if so, what version...

    try {
        VirtualUniverse vu = new VirtualUniverse();
        Map m = vu.getProperties();
        String s = (String) m.get("j3d.version");
        LOG.info("Detected Java3D version: " + s);
    } catch (Throwable t) {
        LOG.info("Unable to detect Java3D installation");
    }

    // Try and see if native JOGL is installed...

    try {
        System.loadLibrary("jogl");
        ac.setProperty(ApplicationContext.JOGL_DETECTED, Boolean.TRUE);
        LOG.info("Detected native libraries for JOGL");
    } catch (Throwable t) {
        LOG.info("Unable to detect native JOGL installation");
        ac.setProperty(ApplicationContext.JOGL_DETECTED, Boolean.FALSE);
    }

    // Start the local client node to connect to the network and the
    // local archive running on this machine...Thread the connection
    // process so it doesn't block the imageViewerClient creating this
    // instance.  We may not be connected to the given gateway, so the
    // socketServer may go blah...

    final boolean useNetwork = (args.hasOption("nonet")) ? false : true;
    ApplicationPanel.getInstance().addStatusMessage("ImageViewer is starting up, please wait...");
    if (useNetwork)
        LOG.info("Starting imageServer client to join network - please wait...");
    Thread t = new Thread(new Runnable() {
        public void run() {
            try {
                ImageViewerClientNode.getInstance(
                        (String) ApplicationContext.getContext()
                                .getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG),
                        (String) ApplicationContext.getContext()
                                .getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE),
                        useNetwork);
                ApplicationPanel.getInstance().addStatusMessage("Ready");
            } catch (Exception exc) {
                exc.printStackTrace();
            }
        }
    });
    t.setPriority(9);
    t.start();

    this.fullScreen = fullScreen;
    mainFrame.setUndecorated(fullScreen);

    // Set the view to encompass the default screen.

    if (fullScreen) {
        Insets i = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        mainFrame.setLocation(r.x + i.left, r.y + i.top);
        mainFrame.setSize(r.width - i.left - i.right, r.height - i.top - i.bottom);
    } else {
        mainFrame.setSize(1100, 800);
        mainFrame.setLocation(r.x + 200, r.y + 100);
    }

    if (dir != null)
        ApplicationPanel.getInstance().load(dir, type);

    timer = new Timer();
    timer.schedule(new GarbageCollectionTimer(), 5000, 2500);
    mainFrame.setVisible(true);
}

From source file:eu.europa.ec.markt.dss.applet.SignatureApplet.java

@Override
public void init() {
    String lang = getParameter("lang");
    if ("nl".equals(lang)) {
        java.util.Locale.setDefault(new java.util.Locale("nl", "NL"));
    } else {//from   w  w w  .j a v a2  s  .  c  o  m
        java.util.Locale.setDefault(new java.util.Locale("en", "EN"));
    }
    BACK_TEXT = getResourceString("BACK");
    NEXT_TEXT = getResourceString("NEXT");
    FINISH_TEXT = getResourceString("FINISH");
    CANCEL_TEXT = getResourceString("CANCEL");

    super.init();

    model.setServiceUrl(getParameter("serviceUrl"));

    if (getParameter("pkcs12File") != null) {
        model.setPkcs12FilePath(getParameter("pkcs12File"));
    }

    if (getParameter("pkcs11Library") != null) {
        model.setPkcs11LibraryPath(getParameter("pkcs11Library"));
    }

    if (getParameter(PRECONFIGURED_TOKEN_TYPE) != null) {
        SignatureTokenType type = SignatureTokenType.valueOf(getParameter(PRECONFIGURED_TOKEN_TYPE));
        model.setTokenType(type);
        model.setPreconfiguredTokenType(true);
    }

    if (getParameter(SIGNATURE_POLICY) != null) {
        String value = getParameter(SIGNATURE_POLICY);
        if (SignaturePolicy.IMPLICIT.equals(value)) {
            model.setSignaturePolicyType(SignaturePolicy.IMPLICIT);
        } else {
            model.setSignaturePolicyType(SignaturePolicy.EXPLICIT);
            model.setSignaturePolicy(value);
            model.setSignaturePolicyAlgo(getParameter(SIGNATURE_POLICY_ALGO));
            model.setSignaturePolicyValue(Base64.decodeBase64(getParameter(SIGNATURE_POLICY_HASH)));
        }
    }

    if (getParameter(STRICT_RFC3370) != null) {
        String value = getParameter(STRICT_RFC3370);
        try {
            model.setStrictRFC3370Compliance(Boolean.parseBoolean(value));
        } catch (Exception ex) {
            LOG.warning(
                    "Invalid value of " + STRICT_RFC3370 + " stick to " + model.isStrictRFC3370Compliance());
        }
    }

    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if (info.getName().equals("Nimbus")) {
                UIManager.setLookAndFeel(info.getClassName());
                SwingUtilities.updateComponentTreeUI(this);
            }
        }
    } catch (Exception exception) {
        LOG.warning("Look and feel Nimbus cannot be installed");
    }

    String usage = getParameter("usage");
    if (usage == null) {
        usage = "all";
    }

    if (usage.equalsIgnoreCase("all")) {
        registerWizardPanel(new ActivityPanel(model));

        registerWizardPanel(new SelectDocumentForSignaturePanel(model));
        registerWizardPanel(new ChooseSignaturePanel(model));
        registerWizardPanel(new SignatureTokenAPIPanel(model));
        registerWizardPanel(new PKCS11ParamsPanel(model));
        registerWizardPanel(new PKCS12ParamsPanel(model));
        registerWizardPanel(new MOCCAParamsPanel(model));
        registerWizardPanel(new ChooseCertificatePanel(model));
        registerWizardPanel(new PersonalDataPanel(model));
        registerWizardPanel(new SaveDocumentPanel(model));
        registerWizardPanel(new WizardFinishedPanel(model));

        registerWizardPanel(new SelectDocumentForVerificationPanel(model));
        registerWizardPanel(new SignatureValidationReportPanel(model));

        registerWizardPanel(new SelectDocumentForExtensionPanel(model));

        setInitialPanel(ActivityPanel.ID);
        setCurrentPanel(ActivityPanel.ID, true);
    } else if (usage.equalsIgnoreCase("sign")) {
        registerWizardPanel(new SelectDocumentForSignaturePanel(model));
        registerWizardPanel(new ChooseSignaturePanel(model));
        registerWizardPanel(new SignatureTokenAPIPanel(model));
        registerWizardPanel(new PKCS11ParamsPanel(model));
        registerWizardPanel(new PKCS12ParamsPanel(model));
        registerWizardPanel(new MOCCAParamsPanel(model));
        registerWizardPanel(new ChooseCertificatePanel(model));
        registerWizardPanel(new PersonalDataPanel(model));
        registerWizardPanel(new SaveDocumentPanel(model));
        registerWizardPanel(new WizardFinishedPanel(model));

        setInitialPanel(SelectDocumentForSignaturePanel.ID);
        setCurrentPanel(SelectDocumentForSignaturePanel.ID, true);

        model.setWizardUsage(WizardUsage.SIGN);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    } else if (!isUsageParameterValid(usage) || usage.equalsIgnoreCase("verify")) {
        registerWizardPanel(new SelectDocumentForVerificationPanel(model));
        registerWizardPanel(new SignatureValidationReportPanel(model));

        setInitialPanel(SelectDocumentForVerificationPanel.ID);
        setCurrentPanel(SelectDocumentForVerificationPanel.ID, true);

        model.setWizardUsage(WizardUsage.VERIFY);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    } else if (usage.equalsIgnoreCase("extend")) {
        registerWizardPanel(new SelectDocumentForExtensionPanel(model));

        setInitialPanel(SelectDocumentForExtensionPanel.ID);
        setCurrentPanel(SelectDocumentForExtensionPanel.ID, true);

        model.setWizardUsage(WizardUsage.EXTEND);
        model.setUsageParameterFound(true);
        setNextFinishButtonEnabled(true);
    }

    registerWizardPanel(new ErrorPanel(model));

    setFinishedId(WizardFinishedPanel.ID);

    setErrorPanel(ErrorPanel.ID);
}

From source file:com.googlecode.logVisualizer.LogVisualizer.java

private LogVisualizer() {
    try {// w  w w.  j a va2  s .c om
        final String wantedLaf = Settings.getSettingString("LookAndFeel");
        LookAndFeelInfo usedLaf = null;
        for (final LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels())
            if (lafi.getName().equals(wantedLaf)) {
                usedLaf = lafi;
                break;
            }

        if (usedLaf != null)
            UIManager.setLookAndFeel(usedLaf.getClassName());
        else
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final Exception e) {
        e.printStackTrace();
    }

    gui = new LogVisualizerGUI(new LogLoaderListener() {
        public void loadMafiaLog(final File file) {
            loadLog(file, new MafiaLogParser(file, Settings.getSettingBoolean("Include mafia log notes")));
        }

        public void loadPreparsedLog(final File file) {
            loadLog(file, new PreparsedLogParser(file));
        }

        public void loadXMLLog(final File file) {
            try {
                final LogDataHolder logData = XMLLogReader.parseXMLLog(file);
                addLogGUI(file, logData);
            } catch (final FileAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while reading the file.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            } catch (final XMLAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while parsing the XML.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    gui.setSize(800, 600);
    RefineryUtilities.centerFrameOnScreen(gui);
    gui.setVisible(true);

    if (Settings.getSettingBoolean("First program startup")) {
        final JLabel text = new JLabel(
                "<html>Note that <b>for the purpose of logging your own runs with KolMafia, it is best</b> to "
                        + "turn on all options but <i>Log adventures left instead of adventures used</i> under "
                        + "<i>General->Preferences->Session Logs</i> in KolMafia."
                        + "<br><br><br>This informational popup will only be displayed this once.</html>");
        text.setPreferredSize(new Dimension(550, 100));
        JOptionPane.showMessageDialog(gui, text, "KolMafia logging options", JOptionPane.INFORMATION_MESSAGE);

        Settings.setSettingBoolean("First program startup", false);
    }

    if (Settings.getSettingBoolean("Check Updates"))
        new Thread(new Runnable() {
            public void run() {
                if (ProjectUpdateViewer.isNewerVersionUploaded())
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            UpdateDialog.showDialog(gui);
                        }
                    });
            }
        }).start();
}

From source file:net.pms.newgui.LooksFrame.java

public static void initializeLookAndFeel() {
    synchronized (lookAndFeelInitializedLock) {
        if (lookAndFeelInitialized) {
            return;
        }/*w  ww. ja  v a  2  s  .  c om*/

        if (Platform.isWindows()) {
            try {
                UIManager.setLookAndFeel(WINDOWS_LNF);
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException e) {
                LOGGER.error("Error while setting Windows look and feel: ", e);
            }
        } else if (System.getProperty("nativelook") == null && !Platform.isMac()) {
            try {
                UIManager.setLookAndFeel(PLASTICXP_LNF);
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException e) {
                LOGGER.error("Error while setting Plastic XP look and feel: ", e);
            }
        } else {
            try {
                String systemClassName = UIManager.getSystemLookAndFeelClassName();
                // Workaround for Gnome
                try {
                    String gtkLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
                    Class.forName(gtkLAF);

                    if (systemClassName.equals("javax.swing.plaf.metal.MetalLookAndFeel")) {
                        systemClassName = gtkLAF;
                    }
                } catch (ClassNotFoundException ce) {
                    LOGGER.error("Error loading GTK look and feel: ", ce);
                }

                LOGGER.trace("Choosing Java look and feel: " + systemClassName);
                UIManager.setLookAndFeel(systemClassName);
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException e1) {
                try {
                    UIManager.setLookAndFeel(PLASTICXP_LNF);
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                        | UnsupportedLookAndFeelException e) {
                    LOGGER.error("Error while setting Plastic XP look and feel: ", e);
                }
                LOGGER.error("Error while setting native look and feel: ", e1);
            }
        }

        if (isParticularLaFSet(UIManager.getLookAndFeel(), PLASTICXP_LNF)) {
            PlasticLookAndFeel.setPlasticTheme(PlasticLookAndFeel.createMyDefaultTheme());
            PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_DEFAULT_VALUE);
            PlasticLookAndFeel.setHighContrastFocusColorsEnabled(false);
        } else if (isParticularLaFSet(UIManager.getLookAndFeel(), METAL_LNF)) {
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }

        // Work around caching in MetalRadioButtonUI
        JRadioButton radio = new JRadioButton();
        radio.getUI().uninstallUI(radio);
        JCheckBox checkBox = new JCheckBox();
        checkBox.getUI().uninstallUI(checkBox);

        // Workaround for JDK-8179014: JFileChooser with Windows look and feel crashes on win 10
        // https://bugs.openjdk.java.net/browse/JDK-8179014
        if (isParticularLaFSet(UIManager.getLookAndFeel(), WINDOWS_LNF)) {
            UIManager.put("FileChooser.useSystemExtensionHiding", false);
        }

        lookAndFeelInitialized = true;
    }
}

From source file:EditorPaneExample11.java

public static void main(String[] args) {
    try {//ww w.  j  av a2 s . c om
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new EditorPaneExample11();

    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java

private void showErrorWindow(String title, String body) {
    try {/*w w w.  j ava2 s. c  om*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            System.setProperty("apple.awt.UIElement", "false");

        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        JTextArea textArea = new JTextArea(body);
        JScrollPane scrollPane = new JScrollPane(textArea);
        textArea.setLineWrap(true);
        textArea.setFont(Font.getFont(Font.MONOSPACED));
        textArea.setEditable(false);
        textArea.setWrapStyleWord(true);
        scrollPane.setPreferredSize(new Dimension(500, 500));

        JTextPane titleLabel = new JTextPane();
        titleLabel.setContentType("text/html"); // let the text pane know this is what you want
        titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off
        titleLabel.setEditable(false);
        titleLabel.setBackground(null);
        titleLabel.setBorder(null);

        panel.add(titleLabel);
        panel.add(scrollPane);

        final JFrame frame = new JFrame();
        frame.setAlwaysOnTop(true);
        moveCenter(frame);
        frame.setVisible(true);

        JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.",
                JOptionPane.CLOSED_OPTION);
        System.exit(1);
    } catch (Exception e) {
        log.error("Problem showing error window", e);
    }
}

From source file:com.floreantpos.main.SetUpWindow.java

private void setLookAndFeel() {
    try {//from   w  ww .  ja  v  a2  s . c  o m
        PlasticXPLookAndFeel.setPlasticTheme(new ExperienceBlue());
        UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
        initializeFont();
    } catch (Exception ignored) {
    }
}

From source file:de.codesourcery.eve.skills.ui.Main.java

protected static void setLookAndFeel() {

    LookAndFeelInfo newLandF = null;//w  w  w  .j a  v a  2  s  .  c  o  m
    for (LookAndFeelInfo lf : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(lf.getName())) {
            newLandF = lf;
            break;
        }
    }

    if (newLandF != null) {
        try {
            UIManager.setLookAndFeel(newLandF.getClassName());
        } catch (Exception e) {
            log.error("setLookAndFeel(): Failed to change look and feel", e);
        }
    } else {
        log.info("setLookAndFeel(): L&F 'Nimbus' not available, using default.");
    }
}