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:com._17od.upm.gui.MainWindow.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                // Use the System look and feel
                Preferences.load();
                Translator.initialise();
                Double jvmVersion = new Double(System.getProperty("java.specification.version"));
                if (jvmVersion.doubleValue() < 1.4) {
                    JOptionPane.showMessageDialog(null, Translator.translate("requireJava14"),
                            Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
                    System.exit(1);
                } else {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    AppWindow = new MainWindow(applicationName);
                }//from  w w  w. j a  v  a 2 s.c  om

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

From source file:Main.java

public static void main_helper(String args[]) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setSize(300, 300);//from  w w w .  j  a  v a  2 s.c  o  m

    f.setUndecorated(true);
    f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

    JPanel panel = new JPanel();
    panel.setBackground(java.awt.Color.white);
    f.setContentPane(panel);

    MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme());

    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (Exception e) {
        e.printStackTrace();
    }

    SwingUtilities.updateComponentTreeUI(f);

    f.setVisible(true);

}

From source file:Main.java

/**
 * Sets the system look and feel./*from   ww w . j a v  a2s .  c o  m*/
 * If this is not possible, this returns false. 
 * Otherwise, this sets the system look and feel and returns true.
 */
public static boolean setSystemLAF() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
        return false;
    } catch (InstantiationException e) {
        return false;
    } catch (IllegalAccessException e) {
        return false;
    } catch (UnsupportedLookAndFeelException e) {
        return false;
    }
    return true;
}

From source file:Main.java

/**
 * Set the look and feel of the application
 * //  w ww .j  a v a2  s .co  m
 * @param lookAndFeel
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws UnsupportedLookAndFeelException
 */
public static void setLookAndFeel(String lookAndFeel) throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, UnsupportedLookAndFeelException {
    String className = null;
    for (LookAndFeelInfo l : UIManager.getInstalledLookAndFeels()) {
        if (l.getName().equalsIgnoreCase(lookAndFeel)) {
            className = l.getClassName();
            break;
        }
    }
    if (className != null)
        UIManager.setLookAndFeel(className);
}

From source file:Main.java

/**
 * Try to set the default look and feel.
 *//*from  w  w w . j  a v a  2  s  .  co  m*/
public static void setLookAndFeel() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void setLookAndFeel(LookAndFeel laf, JFrame frame) {
    try {/*from w  w  w .j a  v  a2  s.c  o m*/
        UIManager.setLookAndFeel(laf);
        if (frame != null) {
            SwingUtilities.updateComponentTreeUI(frame);
            frame.pack();
        }
    } catch (UnsupportedLookAndFeelException e) {
        System.err.println("This Look and Feel is not supported!");
        e.printStackTrace();
    }
}

From source file:jfreechart.ViewGirlsBoysAvgChart.java

public static void viweGirlsAvgChart(List<String> testId, ArrayList<Double> totAvg, ArrayList<Double> girlsAvg,
        ArrayList<Double> boysAvg) throws SQLException, ClassNotFoundException {
    try {/*from w w  w  .  j a  v a2  s .  c  o  m*/
        UIManager.setLookAndFeel(new McWinLookAndFeel());
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(ViewEachStudentChart.class.getName()).log(Level.SEVERE, null, ex);
    }
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();

    for (Double marks : totAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line1", marks);

    }
    for (Double marks : girlsAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line2", marks);

    }
    //        for (Double testMark : bAvgList) {
    //            Double mark = testMark;
    //            //String tstId = testId.split(",")[3];
    //            objDataset.setValue(mark, "", mark);
    //            
    //            
    //        }
    JFreeChart objChart = ChartFactory.createLineChart("Marks Chart", //Chart title
            "Test", //Domain axis label
            "Marks", //Range axis label
            objDataset, //Chart Data 
            PlotOrientation.VERTICAL, // orientation
            true, // include legend?
            true, // include tooltips?
            false // include URLs?
    );

    ChartFrame frame = new ChartFrame("Dakma Higher Education Center", objChart);
    frame.setLocationRelativeTo(frame);
    frame.pack();
    frame.setVisible(true);
}

From source file:net.erdfelt.android.sdkfido.ui.utils.UIUtils.java

public static void setDefaultLookAndFeel() {
    try {/*  w w w  . j  a va 2 s .co  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Unable to set System Look and Feel.", e);
    }

    JFrame.setDefaultLookAndFeelDecorated(true);
}

From source file:appStructure.MainApp.java

/**
 * /* w  w w  .j ava2  s . com*/
 */
private static void setLookAndFeel() {
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (ClassNotFoundException e) {
        System.err.println(
                "Couldn't find class for specified look and feel:" + "javax.swing.plaf.metal.MetalLookAndFeel");
        System.err.println("Did you include the L&F library in the class path?");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    } catch (InstantiationException e) {

        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        System.err.println("Can't use the specified look and feel (" + "javax.swing.plaf.metal.MetalLookAndFeel"
                + ") on this platform.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    } catch (Exception e) {
        System.err.println("Couldn't get specified look and feel (" + "javax.swing.plaf.metal.MetalLookAndFeel"
                + "), for some reason.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Tries to set the LookAndFeel to the os default
 * /*  w ww  .  jav  a  2s .c  om*/
 * @return if the system look and feel could be set
 */
public static boolean setSystemLookAndFeel() {
    boolean isSystemLookAndFeelSet = true;
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        isSystemLookAndFeelSet = false;
    }
    return isSystemLookAndFeelSet;
}