Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.*;

public class Main {
    /**
     * Tries to set the NimbusLookAndFeel
     * 
     * @return if the NimbusLookAndFeel could bet set
     */
    public static boolean setNimbusLookAndFeel() {
        boolean isNumbusSet = true;
        try { // Nimbus Loyout
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException e) {
            isNumbusSet = false;
        } catch (InstantiationException e) {
            isNumbusSet = false;
        } catch (IllegalAccessException e) {
            isNumbusSet = false;
        } catch (UnsupportedLookAndFeelException e) {
            isNumbusSet = false;
        }
        return isNumbusSet;

        /*
         * try {//alternative way for (LookAndFeelInfo info :
         * UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {
         * UIManager.setLookAndFeel(info.getClassName()); break; } } } catch
         * (UnsupportedLookAndFeelException e) { } catch (ClassNotFoundException e) { } catch
         * (InstantiationException e) { } catch (IllegalAccessException e) { }
         */
    }
}