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:src.gui.ItSIMPLE.java

/**
 * This method initializes metalItem/*from  ww w.  j a  v a 2s  .  com*/
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getMetalMenuItem() {
    if (metalMenuItem == null) {
        metalMenuItem = new JMenuItem();
        metalMenuItem.setText("Metal");
        metalMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
                    SwingUtilities.updateComponentTreeUI(instance);
                    instance.pack();
                    itSettings.getChild("generalSettings").getChild("graphics").getChild("appearence")
                            .setText("Metal");
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
    }
    return metalMenuItem;
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes motifItem//ww w .j a  v  a  2 s. c  o  m
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getMotifMenuItem() {
    if (motifMenuItem == null) {
        motifMenuItem = new JMenuItem();
        motifMenuItem.setText("CDE/Motif");
        motifMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                    SwingUtilities.updateComponentTreeUI(instance);
                    itSettings.getChild("generalSettings").getChild("graphics").getChild("appearence")
                            .setText("Motif");
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
    }
    return motifMenuItem;
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes defaultItem/*  w ww. jav a  2 s.co  m*/
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getDefaultMenuItem() {
    if (defaultMenuItem == null) {
        defaultMenuItem = new JMenuItem();
        defaultMenuItem.setText("Default");
        defaultMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    SwingUtilities.updateComponentTreeUI(instance);
                    itSettings.getChild("generalSettings").getChild("graphics").getChild("appearence")
                            .setText("Default");
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
    }
    return defaultMenuItem;
}

From source file:library.Form_Library.java

License:asdf

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    try {/*  w ww .  ja  va 2s  . c  o  m*/
        // Set cross-platform Java L&F (also called "Metal")
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
        // handle exception
    } catch (ClassNotFoundException e) {
        // handle exception
    } catch (InstantiationException e) {
        // handle exception
    } catch (IllegalAccessException e) {
        // handle exception
    }
}

From source file:library.Form_Library.java

License:asdf

/**
 * @param args the command line arguments
 *///from   ww w  .ja  v  a  2s  .  c o  m
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Form_Library.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Form_Library.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Form_Library.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Form_Library.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Form_Library().setVisible(true);
        }
    });

}

From source file:in.gov.uidai.auth.sampleapp.SampleClientMainFrame.java

/**
 * @param args/*from   w  ww .  jav a 2s  . c o  m*/
 *            the command line arguments
 */
public static void main(String args[]) {

    try {
        // Set System L&F
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (Exception e) {
        e.printStackTrace();
    }

    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            try {
                new SampleClientMainFrame().setVisible(true);

            } catch (URISyntaxException ex) {
                Logger.getLogger(SampleClientMainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:edu.ku.brc.specify.utilapps.BuildSampleDatabase.java

/**
 * @param args// w  ww .j  a v  a  2 s.  com
 */
public static void main(final String[] args) {
    System.setProperty(DBMSUserMgr.factoryName, "edu.ku.brc.dbsupport.MySQLDMBSUserMgr");
    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

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

    new HiddenTableMgr();
    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (StringUtils.isEmpty(getAppName())) {
        setAppName("Specify");
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            BuildSampleDatabase builder = new BuildSampleDatabase();
            builder.buildSetup(args);
        }
    });
}

From source file:src.gui.ItSIMPLE.java

/**
 * @param argsu/*w  w w  .  j a v  a  2s  . c  o m*/
 */
public static void main(String[] args) {

    //get CommonDatapddlVer
    Document commonDoc = null;
    try {
        commonDoc = XMLUtilities.readFromFile("resources/settings/commonData.xml");

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (commonDoc != null) {
        commonData = commonDoc.getRootElement();
    }

    // Get settings from itSettings.xml
    org.jdom.Document itSettingsDoc = null;
    try {
        itSettingsDoc = XMLUtilities.readFromFile("resources/settings/itSettings.xml");
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    if (itSettingsDoc != null) {
        itSettings = itSettingsDoc.getRootElement();
    }

    // Get planners from itPlanners
    org.jdom.Document itPlannersDoc = null;
    try {
        itPlannersDoc = XMLUtilities.readFromFile("resources/planners/itPlanners.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (itPlannersDoc != null) {
        itPlanners = itPlannersDoc.getRootElement();
    }

    // Get validators from itValidators
    org.jdom.Document itValidatorsDoc = null;
    try {
        itValidatorsDoc = XMLUtilities.readFromFile("resources/validators/itValidators.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (itPlannersDoc != null) {
        itValidators = itValidatorsDoc.getRootElement();
    }

    try {
        String appearence = itSettings.getChild("generalSettings").getChild("graphics")
                .getChildText("appearence");
        if (appearence.equals("Default")) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else if (appearence.equals("Windows")) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // Windows
        } else if (appearence.equals("Metal")) {
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); // Metal
        } else if (appearence.equals("Motif")) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // Motif
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }

        // Need installation
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); // GTK+
        //UIManager.setLookAndFeel("javax.swing.plaf.mac.MacLookAndFeel"); // Mac

    } catch (Exception e) {
        //e.printStackTrace();
    }
    SplashScreen splash = new SplashScreen(5000);
    Thread t = new Thread(splash);
    t.start();
    ItSIMPLE.getInstance();

    WindowEventHandler closeWind = new WindowEventHandler();
    closeWind.itsimpleInst = instance;
    instance.addWindowListener(closeWind);
    instance.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    //instance = new ItSIMPLE();
    instance.setVisible(true);
    instance.setExtendedState(JFrame.MAXIMIZED_BOTH);
    //instance.repaint();
    //infoPanel.minimize();

}

From source file:net.sourceforge.squirrel_sql.client.Application.java

/**
 * Setup applications Look and Feel.//  w w w . j  ava 2s.c  o  m
 */
private void setupLookAndFeel(ApplicationArguments args) {
    /* 
     * Don't prevent the user from overriding the laf is they choose to use 
     * Swing's default laf prop 
     */
    String userSpecifiedOverride = System.getProperty("swing.defaultlaf");
    if (userSpecifiedOverride != null && !"".equals(userSpecifiedOverride)) {
        return;
    }

    String lafClassName = args.useNativeLAF() ? UIManager.getSystemLookAndFeelClassName()
            : MetalLookAndFeel.class.getName();

    if (!args.useDefaultMetalTheme()) {
        MetalLookAndFeel.setCurrentTheme(new AllBluesBoldMetalTheme());
    }

    try {
        // The following is a work-around for the problem on Mac OS X where
        // the Apple LAF delegates to the Swing Popup factory but then
        // tries to set a 90% alpha on the underlying Cocoa window, which
        // will always be null if you're using JGoodies L&F
        // see http://www.caimito.net/pebble/2005/07/26/1122392314480.html#comment1127522262179
        // This has no effect on Linux/Windows
        PopupFactory.setSharedInstance(new PopupFactory());

        UIManager.setLookAndFeel(lafClassName);
    } catch (Exception ex) {
        // i18n[Application.error.setlaf=Error setting LAF]
        s_log.error(s_stringMgr.getString("Application.error.setlaf"), ex);
    }
}

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Activeate Substance Look&Feel./*from   w ww  .  j a  v a2 s.  c  om*/
 *
 * Must be called before opening any window.
 * 
 * @param laf Desired Substance Look&Feel class
 */
public static void setSubstanceLAF(String laf) {
    try {
        UIManager.setLookAndFeel(laf);
        UIManager.put(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, Boolean.FALSE);
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        // Substance forgot to put a border for JTextArea,
        // So we give it the same border that TextField has
        Object border = UIManager.get("TextField.border");
        UIManager.put("TextArea.border", border);
        // Plain title font
        //            SubstanceLookAndFeel.setFontPolicy(new FontPolicy() {
        //                public FontSet getFontSet(String arg0, UIDefaults arg1) {
        //                    FontSet fontSet = new FontSet() {
        //                        public FontUIResource getWindowTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); //this is where the title font changes
        //                        }
        //
        //                        public FontUIResource getTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getSmallFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMessageFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMenuFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getControlFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //                    };
        //                    return fontSet;
        //                }
        //            });        
    } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
            | IllegalAccessException ex) {
        Logger.getLogger(GUIToolkit.class.getName()).log(Level.SEVERE, null, ex);
    }
}