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:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java

/**
 * Listener for events from this menu./*from w w  w . j  av  a 2 s . com*/
 */
public void actionPerformed(ActionEvent e) {
    String numStr = e.getActionCommand();
    MetalTheme selectedTheme = themes[Integer.parseInt(numStr)];
    MetalLookAndFeel.setCurrentTheme(selectedTheme);

    try {
        // I18N: Do not localize next statement.
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
        log.error(themeNames.getString("message.error.failedLoadingMetal"), ex);
    }
}

From source file:com.mascova.solus.ui.ClientApplication.java

public ClientApplication(String[] argv) {

    System.out.println(System.getProperty("user.dir"));

    ac = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext-jpa.xml",
            "/META-INF/spring/applicationContext.xml");
    loginService = ac.getBean(LoginService.class);
    authService = ac.getBean(AuthService.class);
    systemLookupService = ac.getBean(SystemLookupService.class);
    clientFacade = new DeskClientFacade(ac);

    // BEGIN Create dummy data

    //        SqlUtil.importCsvData();

    //        DataGenerator dg = ac.getBean(DataGenerator.class);
    //        PersonDataOnDemand pdod = ac.getBean(PersonDataOnDemand.class);
    //        dg.insertMenuData();
    //        pdod.init();

    // END Create dummy data        

    Hashtable domains = new Hashtable();

    List<SystemLookup> genderSystemLookup = systemLookupService.findByType("GNDR");
    Domain genderDomain = new Domain("GNDR");
    for (SystemLookup systemLookup : genderSystemLookup) {
        genderDomain.addDomainPair(systemLookup.getCode(), systemLookup.getLiteral());
    }//from   www  .ja v a 2s  . com

    List<SystemLookup> statusSystemLookup = systemLookupService.findByType("STATUS");
    Domain statusDomain = new Domain("STATUS");
    for (SystemLookup systemLookup : statusSystemLookup) {
        statusDomain.addDomainPair(systemLookup.getType(), systemLookup.getLiteral());
    }

    domains.put(genderDomain.getDomainId(), genderDomain);
    domains.put(statusDomain.getDomainId(), statusDomain);

    Properties licenseProp = new Properties();
    licenseProp.put("systemTextFont", "Arial PLAIN 8");
    licenseProp.put("controlTextFont", "Arial PLAIN 8");
    licenseProp.put("menuTextFont", "Arial PLAIN 8");
    licenseProp.put("userTextFont", "Arial PLAIN 8");
    licenseProp.put("subTextFont", "Arial PLAIN 8");

    ClientSettings clientSettings = new ClientSettings(new EnglishOnlyResourceFactory("E", licenseProp, true),
            domains);
    //        ClientSettings clientSettings = new ClientSettings(
    //                new IndonesiaOnlyResourceFactory("E", licenseProp, true),
    //                domains);

    //    Enumeration k = System.getProperties().keys();
    //    while(k.hasMoreElements()) {
    //      String kk = k.nextElement().toString();
    //      System.out.println(kk+"="+System.getProperty(kk));
    //    }
    //    System.out.println(ClientSettings.LOOK_AND_FEEL_CLASS_NAME);

    //        ClientSettings.LOOK_AND_FEEL_CLASS_NAME =
    //                "javax.swing.plaf.nimbus.NimbusLookAndFeel";
    ClientSettings.LOOK_AND_FEEL_CLASS_NAME = "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel";

    Properties props = new Properties();
    props.put("logoString", "Solus");
    String color = "220 220 220";
    props.put("selectionBackgroundColor", color);
    props.put("menuSelectionBackgroundColor", color);
    props.put("backgroundColor", "232 232 232");
    props.put("disabledBackgroundColor", color);
    props.put("systemTextFont", "Arial PLAIN 11");
    props.put("controlTextFont", "Arial PLAIN 11");
    props.put("menuTextFont", "Arial PLAIN 11");
    props.put("userTextFont", "Arial PLAIN 11");
    props.put("subTextFont", "Arial PLAIN 11");
    try {
        try {
            try {
                Class.forName(ClientSettings.LOOK_AND_FEEL_CLASS_NAME)
                        .getMethod("setCurrentTheme", new Class[] { Properties.class })
                        .invoke(null, new Object[] { props });
            } catch (NoSuchMethodException ex) {
                Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SecurityException ex) {
                Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        UIManager.setLookAndFeel(ClientSettings.LOOK_AND_FEEL_CLASS_NAME);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(ClientApplication.class.getName()).log(Level.SEVERE, null, ex);
    }

    ClientSettings.BACKGROUND = "background3.jpg";
    ClientSettings.TREE_BACK = "treeback2.jpg";
    ClientSettings.ICON_FILENAME = "appicon1.png";
    ClientSettings.AUTO_EXPAND_TREE_MENU = true;
    ClientSettings.MIN_MENU_WIDTH = 300;
    ClientSettings.FILTER_PANEL_ON_GRID = true;
    ClientSettings.SHOW_NAVIGATOR_BAR_IN_LOOKUP = true;
    ClientSettings.LOOKUP_FRAME_CONTENT = LookupController.GRID_AND_FILTER_FRAME;
    //    ClientSettings.AUTO_EXPAND_SUBTREE_MENU = "Folder3";
    //    ClientSettings.MAX_MENU_WIDTH = 300;
    //    ClientSettings.MENU_WIDTH = 300;        

    if (argv.length == 1) {
        ClientSettings.LOOK_AND_FEEL_CLASS_NAME = argv[0];
    }

    //        instantiateLoginDialog();
    MDIFrame mdi = new MDIFrame(this);

}

From source file:edu.ku.brc.specify.toycode.UpdatesApp.java

/**
 * @param args/*from w  w  w  .j a  v a2  s . c  o m*/
 */
public static void main(String[] args) {
    if (args.length == 9) {
        for (int i = 0; i < args.length; i++) {
            System.out.println(i + "=" + args[i]);
        }
        doingCmdLine = true;
        UpdatesApp updateApp = new UpdatesApp();
        try {
            updateApp.merge(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
        } catch (java.lang.NullPointerException ex) {
            System.err.println("****The merge process failed:  check for errors above.");
        }

    } else {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                try {
                    UIHelper.OSTYPE osType = UIHelper.getOSType();
                    if (osType == UIHelper.OSTYPE.Windows) {
                        //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                    } else if (osType == UIHelper.OSTYPE.Linux) {
                        //UIManager.setLookAndFeel(new GTKLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        //PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertGreen());

                    }
                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(UpdatesApp.class, e);
                    System.err.println("Can't change L&F: " + e); //$NON-NLS-1$
                }

                UpdatesApp panel = new UpdatesApp();
                JFrame frame = new JFrame();
                frame.setTitle("Install4J XML Updater");
                frame.setContentPane(panel);

                JMenuBar menuBar = panel.createMenus();
                if (menuBar != null) {
                    //top.add(menuBar, BorderLayout.NORTH);
                    frame.setJMenuBar(menuBar);
                }

                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}

From source file:facturas.PDF.CommandLineOptions.java

/**
 * Parse the command line arguments./*  w  w w  .j  a  va  2  s .  c  om*/
 *
 * @param args
 *            the command line arguments.
 * @throws FOPException
 *             for general errors
 * @throws FileNotFoundException
 *             if an input file wasn't found
 * @throws IOException
 *             if the the configuration file could not be loaded
 */
public void parse(String[] args) throws FOPException, IOException {
    boolean optionsParsed = true;

    try {
        optionsParsed = parseOptions(args);
        if (optionsParsed) {
            if (showConfiguration == Boolean.TRUE) {
                dumpConfiguration();
            }
            checkSettings();
            setUserConfig();

            // Factory config is set up, now we can create the user agent
            foUserAgent = factory.newFOUserAgent();
            foUserAgent.getRendererOptions().putAll(renderingOptions);
            if (targetResolution != 0) {
                foUserAgent.setTargetResolution(targetResolution);
            }
            addXSLTParameter("fop-output-format", getOutputFormat());
            addXSLTParameter("fop-version", Version.getVersion());
        }
    } catch (FOPException e) {
        printUsage();
        throw e;
    } catch (java.io.FileNotFoundException e) {
        printUsage();
        throw e;
    }

    inputHandler = createInputHandler();

    if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) {
        // set the system look&feel for the preview dialog
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println("Couldn't set system look & feel!");
        }

        AWTRenderer renderer = new AWTRenderer(true);
        renderer.setRenderable(inputHandler); // set before user agent!
        renderer.setUserAgent(foUserAgent);
        foUserAgent.setRendererOverride(renderer);
    } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode) && mimicRenderer != null) {
        // render from FO to Intermediate Format
        Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(foUserAgent, mimicRenderer);
        XMLRenderer xmlRenderer = new XMLRenderer();
        xmlRenderer.setUserAgent(foUserAgent);

        // Tell the XMLRenderer to mimic the target renderer
        xmlRenderer.mimicRenderer(targetRenderer);

        // Make sure the prepared XMLRenderer is used
        foUserAgent.setRendererOverride(xmlRenderer);
    }
}

From source file:EditorPaneExample16.java

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

    JFrame f = new EditorPaneExample16();

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

From source file:EditorPaneExample13.java

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

    JFrame f = new EditorPaneExample13();

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

From source file:net.sf.texprinter.utils.UIUtils.java

/**
* Set the native look and feel according to the operating system.
*//*from   w  w  w . j av  a2  s  . c  om*/
public static void setAluminiumLookAndFeel() {

    // let's try
    try {

        // set the aluminium look and feel as the system look and feel
        UIManager.setLookAndFeel(new AluminiumLookAndFeel());

    } catch (Exception e) {
        // something happened, but we won't do nothing
    }
}

From source file:EditorPaneExample14.java

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

    JFrame f = new EditorPaneExample14();

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

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

public void setLookAndFeel(String uiclassname) {
    try {//ww  w  . ja va 2  s  .c o m
        UIManager.setLookAndFeel(uiclassname);
        SwingUtilities.updateComponentTreeUI(this);
        Prefs.setString("looknfeel", uiclassname);
        Prefs.save();
    } catch (ClassNotFoundException e1) {
        LOG.warning("Unable to set Look and Feel (it is missing).");
    } catch (InstantiationException e1) {
        LOG.warning("Unable to set Look and Feel (cannot be instantiated by JRE).");
    } catch (IllegalAccessException e1) {
        LOG.warning("Unable to set Look and Feel (cannot be used by JRE).");
    } catch (UnsupportedLookAndFeelException e1) {
        LOG.warning("Unable to set Look and Feel (not supported by JRE).");
    }
}

From source file:components.TreeDemo.java

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

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

    //Add content to the window.
    frame.add(new TreeDemo());

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