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:lab4.YouQuiz.java

public static void main(String args[]) {
    try {//from  ww  w  .j  a va  2s.c o  m
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Windows".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex);
    }

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                new YouQuiz().setVisible(true);
            } catch (IOException ex) {
                Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:EditorPaneExample17.java

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

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

From source file:com.mirth.connect.client.ui.Mirth.java

public static void initUIManager() {
    try {//from ww  w .  j  a  v  a 2s  .c o m
        PlasticLookAndFeel.setPlasticTheme(new MirthTheme());
        PlasticXPLookAndFeel look = new PlasticXPLookAndFeel();
        UIManager.setLookAndFeel(look);
        UIManager.put("win.xpstyle.name", "metallic");
        LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class);

        /*
         * MIRTH-1225 and MIRTH-2019: Create alternate key bindings if CTRL is not the same as
         * the menu shortcut key (i.e. COMMAND on OSX)
         */
        if (InputEvent.CTRL_MASK != Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) {
            createAlternateKeyBindings();
        }

        if (SystemUtils.IS_OS_MAC) {
            OSXAdapter.setAboutHandler(Mirth.class, Mirth.class.getDeclaredMethod("aboutMac", (Class[]) null));
            OSXAdapter.setQuitHandler(Mirth.class, Mirth.class.getDeclaredMethod("quitMac", (Class[]) null));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // keep the tooltips from disappearing
    ToolTipManager.sharedInstance().setDismissDelay(3600000);

    // TabbedPane defaults
    // UIManager.put("TabbedPane.selected", new Color(0xffffff));
    // UIManager.put("TabbedPane.background",new Color(225,225,225));
    // UIManager.put("TabbedPane.tabAreaBackground",new Color(225,225,225));
    UIManager.put("TabbedPane.highlight", new Color(225, 225, 225));
    UIManager.put("TabbedPane.selectHighlight", new Color(0xc3c3c3));
    UIManager.put("TabbedPane.contentBorderInsets", new InsetsUIResource(0, 0, 0, 0));

    // TaskPane defaults
    UIManager.put("TaskPane.titleBackgroundGradientStart", new Color(0xffffff));
    UIManager.put("TaskPane.titleBackgroundGradientEnd", new Color(0xffffff));

    // Set fonts
    UIManager.put("TextPane.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ToggleButton.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("Panel.font", UIConstants.DIALOG_FONT);
    UIManager.put("PopupMenu.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("OptionPane.font", UIConstants.DIALOG_FONT);
    UIManager.put("Label.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("Tree.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ScrollPane.font", UIConstants.DIALOG_FONT);
    UIManager.put("TextField.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("Viewport.font", UIConstants.DIALOG_FONT);
    UIManager.put("MenuBar.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("FormattedTextField.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("DesktopIcon.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("TableHeader.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ToolTip.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("PasswordField.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("TaskPane.font", UIConstants.TEXTFIELD_BOLD_FONT);
    UIManager.put("Table.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("TabbedPane.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ProgressBar.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("CheckBoxMenuItem.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ColorChooser.font", UIConstants.DIALOG_FONT);
    UIManager.put("Button.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("TextArea.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("Spinner.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("RadioButton.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("TitledBorder.font", UIConstants.TEXTFIELD_BOLD_FONT);
    UIManager.put("EditorPane.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("RadioButtonMenuItem.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ToolBar.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("MenuItem.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("CheckBox.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("JXTitledPanel.title.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("Menu.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("ComboBox.font", UIConstants.TEXTFIELD_PLAIN_FONT);
    UIManager.put("JXLoginPanel.banner.font", UIConstants.BANNER_FONT);
    UIManager.put("List.font", UIConstants.TEXTFIELD_PLAIN_FONT);

    InputMap im = (InputMap) UIManager.get("Button.focusInputMap");
    im.put(KeyStroke.getKeyStroke("pressed ENTER"), "pressed");
    im.put(KeyStroke.getKeyStroke("released ENTER"), "released");

    try {
        UIManager.put("wizard.sidebar.image",
                ImageIO.read(com.mirth.connect.client.ui.Frame.class.getResource("images/wizardsidebar.png")));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:llc.rockford.webcast.EC2Driver.java

private void initLookAndFeel() {
    String lookAndFeel = null;/*from w  w  w .  j ava 2  s. c o m*/

    if (LOOKANDFEEL != null) {
        if (LOOKANDFEEL.equals("Metal")) {
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        } else if (LOOKANDFEEL.equals("System")) {
            lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        } else if (LOOKANDFEEL.equals("Motif")) {
            lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        } else if (LOOKANDFEEL.equals("GTK")) {
            lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        } else {
            System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        }
        try {
            UIManager.setLookAndFeel(lookAndFeel);
            // If L&F = "Metal", set the theme
            if (LOOKANDFEEL.equals("Metal")) {
                if (THEME.equals("DefaultMetal"))
                    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
                else if (THEME.equals("Ocean"))
                    MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            }
        } catch (ClassNotFoundException e) {
            System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel);
            System.err.println("Did you include the L&F library in the class path?");
            System.err.println("Using the default look and feel.");
        } catch (UnsupportedLookAndFeelException e) {
            System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform.");
            System.err.println("Using the default look and feel.");
        } catch (Exception e) {
            System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
            System.err.println("Using the default look and feel.");
            e.printStackTrace();
        }
    }
}

From source file:QueryConnector.java

/** Gestione degli eventi **/
public static void attach(XComponentContext componentContext, XModel model) {
    QueryConnector connector = null;//from w  w w . j  a v a2  s  .  c o m
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        connector = new QueryConnector(model, componentContext);
        connector.attach();
    } catch (Exception ex) {
        if (connector != null)
            connector.enableEdit();
        ExceptionDialog.show(null, ex);
    }
}

From source file:org.moeaframework.examples.gp.regression.SymbolicRegressionGUI.java

/**
 * Runs the given symbolic regression problem instance, displaying
 * intermediate results in a GUI./*from   w ww.jav  a 2  s.  c o  m*/
 * 
 * @param problem the symbolic regression problem instance
 */
public static void runDemo(SymbolicRegression problem) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        // couldn't set system look and feel, continue with default
    }

    // setup the GUI
    SymbolicRegressionGUI gui = new SymbolicRegressionGUI(problem);

    // setup and construct the GP solver
    int generation = 0;
    int maxGenerations = 1000;
    Algorithm algorithm = null;
    Properties properties = new Properties();
    properties.setProperty("populationSize", "500");

    try {
        algorithm = AlgorithmFactory.getInstance().getAlgorithm("GA", properties, problem);

        // run the GP solver
        while ((generation < maxGenerations) && !gui.isCanceled()) {
            algorithm.step();
            generation++;

            gui.update(algorithm.getResult().get(0), generation, maxGenerations);
        }
    } finally {
        if (algorithm != null) {
            algorithm.terminate();
        }
    }
}

From source file:edu.wustl.xipHost.hostControl.HostConfigurator.java

public static void main(String[] args) {
    try {/*  w w w  .  j a v  a  2 s.co m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (ClassNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (InstantiationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IllegalAccessException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (UnsupportedLookAndFeelException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    //Turn off commons loggin for better performance
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
    DOMConfigurator.configure("log4j.xml");
    hostConfigurator = new HostConfigurator();
    boolean startupOK = hostConfigurator.runHostStartupSequence();
    if (startupOK == false) {
        logger.fatal("XIPHost startup error. System exits.");
        System.exit(0);
    }
    /*final long MEGABYTE = 1024L * 1024L;
    System.out.println("Total heap size: " + (Runtime.getRuntime().maxMemory())/MEGABYTE);
    System.out.println("Used heap size: " + (Runtime.getRuntime().totalMemory())/MEGABYTE);
    System.out.println("Free heap size: " + (Runtime.getRuntime().freeMemory())/MEGABYTE);*/
}

From source file:TreeDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from   ww w . j a  v a2s .c o  m
 */
private static void createAndShowGUI() {
    if (useSystemLookAndFeel) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println("Couldn't use system look and feel.");
        }
    }

    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("TreeDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    TreeDemo newContentPane = new TreeDemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:javazoom.jlgui.player.amp.StandalonePlayer.java

/**
 * Load player front-end.//  w ww.  j av  a2  s  .co m
 */
public void loadUI() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        log.debug(ex);
    }
    config = Config.getInstance();
    config.load(initConfig);
    config.setTopParent(this);
    if (showPlaylist != null) {
        if (showPlaylist.equalsIgnoreCase("true")) {
            config.setPlaylistEnabled(true);
        } else {
            config.setPlaylistEnabled(false);
        }
    }
    if (showEqualizer != null) {
        if (showEqualizer.equalsIgnoreCase("true")) {
            config.setEqualizerEnabled(true);
        } else {
            config.setEqualizerEnabled(false);
        }
    }
    if (config.isPlaylistEnabled())
        eqFactor = 2;
    else
        eqFactor = 1;
    setTitle(Skin.TITLETEXT);
    ClassLoader cl = this.getClass().getClassLoader();
    URL iconURL = cl.getResource("javazoom/jlgui/player/amp/jlguiicon.gif");
    if (iconURL != null) {
        ImageIcon jlguiIcon = new ImageIcon(iconURL);
        setIconImage(jlguiIcon.getImage());
        config.setIconParent(jlguiIcon);
    }
    setUndecorated(true);
    mp = new PlayerUI();
    if ((showDsp != null) && (showDsp.equalsIgnoreCase("false"))) {
        mp.getSkin().setDspEnabled(false);
    }
    if (skinPath != null) {
        mp.getSkin().setPath(skinPath);
    }
    mp.getSkin().setSkinVersion(skinVersion);
    mp.loadUI(this);
    setContentPane(mp);
    setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
    eqWin = new JWindow(this);
    eqWin.setContentPane(mp.getEqualizerUI());
    eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
    eqWin.setVisible(false);
    plWin = new JWindow(this);
    plWin.setContentPane(mp.getPlaylistUI());
    plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
    plWin.setVisible(false);
    // Window listener
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            // Closing window (Alt+F4 under Win32)
            close();
        }
    });
    // Keyboard shortcut
    setKeyBoardShortcut();
    // Display front-end
    setLocation(config.getXLocation(), config.getYLocation());
    setVisible(true);
    if (config.isPlaylistEnabled())
        plWin.setVisible(true);
    if (config.isEqualizerEnabled())
        eqWin.setVisible(true);
}

From source file:brainflow.app.toplevel.BrainFlow.java

private void initLookAndFeel() {
    try {/*  w  w  w.  j ava  2  s.co m*/

        String osname = System.getProperty("os.name");
        System.out.println("os name is : " + osname);
        if (osname.toUpperCase().contains("WINDOWS")) {
            log.info("windows");

            com.jidesoft.plaf.LookAndFeelFactory.installDefaultLookAndFeel();
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2007_STYLE);
            //((Office2003Painter) Office2003Painter.getInstance()).setColorName("Metallic");

            //UIManager.setLookAndFeel(new NimbusLookAndFeel());
            //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);

        } else if (osname.toUpperCase().contains("LINUX")) {
            //UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.Plastic3DLookAndFeel());
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);

        } else if (osname.toUpperCase().contains("MAC")) {
            System.setProperty("apple.laf.useScreenMenuBar", "true");
            System.setProperty("com.apple.mrj.application.apple.menu.about.name", "BrainFlow");
            System.setProperty("com.apple.macos.useScreenMenuBar", "true");
            System.setProperty("apple.awt.graphics.UseQuartz", "true");
            System.setProperty("apple.awt.brushMetalLook", "true");
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            //UIManager.setLookAndFeel(new NimbusLookAndFeel());
            //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);
            LookAndFeelFactory.installJideExtension(1);

        }

    } catch (UnsupportedLookAndFeelException e) {
        log.severe("could not createSource look and feel");
    } catch (Throwable ex) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            LookAndFeelFactory.installJideExtension();

        } catch (Throwable ex2) {
            log.severe("could not createSource look and feel");
            throw new RuntimeException("failed to initialize look and feel", ex2);
        }

    }

}