Example usage for javax.swing UIManager getLookAndFeel

List of usage examples for javax.swing UIManager getLookAndFeel

Introduction

In this page you can find the example usage for javax.swing UIManager getLookAndFeel.

Prototype

public static LookAndFeel getLookAndFeel() 

Source Link

Document

Returns the current look and feel or null.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println("  " + UIManager.getLookAndFeel().getName());

    UIManager.LookAndFeelInfo[] inst = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < inst.length; i++) {
        System.out.println("  " + inst[i].getName());
    }/*from w w  w  . j  a  va  2 s.  com*/

    LookAndFeel[] aux = UIManager.getAuxiliaryLookAndFeels();
    if (aux != null) {
        for (int i = 0; i < aux.length; i++) {
            System.out.println("  " + aux[i].getName());
        }
    } else {
        System.out.println("  <NONE>");
    }
    System.out.println("  " + UIManager.getCrossPlatformLookAndFeelClassName());
    System.out.println("  " + UIManager.getSystemLookAndFeelClassName());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Get the currently installed look and feel
    LookAndFeel lf = UIManager.getLookAndFeel();

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}

From source file:UIManagerDefaults.java

public static void main(String[] args) {
    System.out.println("Default L&F:");
    System.out.println("  " + UIManager.getLookAndFeel().getName());

    UIManager.LookAndFeelInfo[] inst = UIManager.getInstalledLookAndFeels();
    System.out.println("Installed L&Fs: ");
    for (int i = 0; i < inst.length; i++) {
        System.out.println("  " + inst[i].getName());
    }//w w w. ja v  a  2  s. co  m

    LookAndFeel[] aux = UIManager.getAuxiliaryLookAndFeels();
    System.out.println("Auxiliary L&Fs: ");
    if (aux != null) {
        for (int i = 0; i < aux.length; i++) {
            System.out.println("  " + aux[i].getName());
        }
    } else {
        System.out.println("  <NONE>");
    }

    System.out.println("Cross-Platform:");
    System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());

    System.out.println("System:");
    System.out.println(UIManager.getSystemLookAndFeelClassName());

    System.exit(0);
}

From source file:edu.harvard.mcz.imagecapture.ImageCaptureApp.java

/**Main method for starting the application.
 * // www  .java 2s.  c  o m
 * @param args are not used.
 */
public static void main(String[] args) {

    log.debug(UIManager.getLookAndFeel());
    log.debug(UIManager.getLookAndFeel().getID());

    if (UIManager.getLookAndFeel().getID().equals("Aqua")) {
        // check for "Aqua"
        try {
            UIManager.setLookAndFeel(
                    // OSX Aqua look and feel uses space on forms much too inefficiently
                    // switch to the normal Java look and feel instead.
                    UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
            log.error(e);
        } catch (ClassNotFoundException e) {
            log.error(e);
        } catch (InstantiationException e) {
            log.error(e);
        } catch (IllegalAccessException e) {
            log.error(e);
        }
    }

    System.out.println("Starting " + APP_NAME + " " + APP_VERSION);
    System.out.println(APP_COPYRIGHT);
    System.out.println(APP_LICENSE);
    log.debug("Starting " + APP_NAME + " " + APP_VERSION);

    // open UI and start
    MainFrame mainFrame = new MainFrame();
    Singleton.getSingletonInstance().setMainFrame(mainFrame);
    Singleton.getSingletonInstance().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Singleton.getSingletonInstance().unsetCurrentUser();
    Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Starting....");
    log.debug("User interface started");

    // Load properties
    ImageCaptureProperties properties = new ImageCaptureProperties();
    Singleton.getSingletonInstance().setProperties(properties);
    log.debug("Properties loaded");

    // Set up a barcode (text read from barcode label for pin) matcher/builder
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_COLLECTION)
            .equals(ImageCaptureProperties.COLLECTION_MCZENT)) {
        // ** Configured for the MCZ Entomology Collection, use MCZ assumptions.
        MCZENTBarcode barcodeTextBuilderMatcher = new MCZENTBarcode();
        Singleton.getSingletonInstance().setBarcodeBuilder((BarcodeBuilder) barcodeTextBuilderMatcher);
        Singleton.getSingletonInstance().setBarcodeMatcher((BarcodeMatcher) barcodeTextBuilderMatcher);
    } else if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_COLLECTION)
            .equals(ImageCaptureProperties.COLLECTION_ETHZENT)) {
        // ** Configured for the ETHZ Entomology Collection, use MCZ assumptions.
        ETHZBarcode barcodeTextBuilderMatcher = new ETHZBarcode();
        Singleton.getSingletonInstance().setBarcodeBuilder((BarcodeBuilder) barcodeTextBuilderMatcher);
        Singleton.getSingletonInstance().setBarcodeMatcher((BarcodeMatcher) barcodeTextBuilderMatcher);
    } else {
        log.error("Configured collection not recognized.  Unable to Start");
        ImageCaptureApp.exit(EXIT_ERROR);
    }

    // Force a login dialog by connecting to obtain record count;
    SpecimenLifeCycle sls = new SpecimenLifeCycle();
    try {
        Singleton.getSingletonInstance().getMainFrame().setCount(sls.findSpecimenCountThrows());
        ImageCaptureApp.doStartUp();
    } catch (ConnectionException e) {
        log.error(e.getMessage());
        ImageCaptureApp.doStartUpNot();
    }

    // Experimental chat support, working on localhost.

    /** 
            
       Context context = null;
       Hashtable contextProperties = new Hashtable(2);
            
       contextProperties.put(Context.PROVIDER_URL,"iiop://127.0.0.1:3700");
       contextProperties.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
       contextProperties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
       contextProperties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
       try {
    context = new InitialContext(contextProperties);
       } catch (NamingException ex) {
    ex.printStackTrace();
       }
       if (context!=null) { 
    ConnectionFactory connectionFactory;
    try {
       connectionFactory = (ConnectionFactory)context.lookup("jms/InsectChatTopicFactory");
       Topic chatTopic = (Topic)context.lookup("jms/InsectChatTopic");
       TopicConnection connection = (TopicConnection) connectionFactory.createConnection();
       TopicSession session = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
       TopicSubscriber subscriber = session.createSubscriber(chatTopic);
       connection.start();
       while (true) {
          Message m = subscriber.receive(1);
          if (m != null) {
             if (m instanceof TextMessage) {
                TextMessage message = (TextMessage) m;
                String originator = message.getStringProperty("Originator");
                String text = message.getText();
                System.out.println("Message: " + originator + ": " + text);
             } else {
                break;
             }
          }
       }
    } catch (NamingException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    } catch (JMSException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }
       }
    } 
      */

}

From source file:org.pegadi.client.ApplicationLauncher.java

public static void main(String[] args) {
    com.sun.net.ssl.internal.ssl.Provider provider = new com.sun.net.ssl.internal.ssl.Provider();
    java.security.Security.addProvider(provider);
    setAllPermissions();/*w  w  w .j  a  v  a 2s  .c o  m*/
    /**
     * If we are on Apples operating system, we would like to use the screen
     * menu bar It is the first property we set in our main method. This is
     * to make sure that the property is set before awt is loaded.
     */
    if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
    }
    Logger log = LoggerFactory.getLogger(ApplicationLauncher.class);
    /**
     * Making sure default L&F is System
     */
    if (!UIManager.getLookAndFeel().getName().equals(UIManager.getSystemLookAndFeelClassName())) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.warn("Unable to change L&F to System", e);
        }
    }

    long start = System.currentTimeMillis();

    // Splash
    Splash splash = new Splash("/images/splash.png");
    splash.setVisible(true);

    splash.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "org/pegadi/client/client-context.xml");
    closeContextOnShutdown(context);

    long timeToLogin = System.currentTimeMillis() - start;
    log.info("Connected OK after {} ms", timeToLogin);
    log.info("Java Version {}", System.getProperty("java.version"));

    splash.dispose();
}

From source file:es.darkhogg.hazelnutt.Hazelnutt.java

/**
 * Runs the application/*from   w  ww. j a  v  a2 s  .c o m*/
 * 
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    // Print some version information
    LOGGER.log(Level.OFF, "----------------");
    LOGGER.info("Hazelnutt " + VERSION);

    LOGGER.trace("Selecting Look&Feel...");

    // Select the L&F from configuration or the default if not present
    String slaf = CONFIG.getString("Hazelnutt.gui.lookAndFeel");
    if (slaf == null) {
        LOGGER.info("Configuration entry for L&F missing, creating default");
        slaf = UIManager.getSystemLookAndFeelClassName();
    }

    // Set it or print an error
    try {
        UIManager.setLookAndFeel(slaf);
    } catch (Exception e) {
        LOGGER.warn("Error while selecting the L&F \"" + slaf + "\", leaving default");
    }

    // Update the configuration with the currently selected L&F
    LookAndFeel laf = UIManager.getLookAndFeel();
    LOGGER.debug("L&F selected: " + laf.getName() + " (" + laf.getClass().getName() + ")");
    CONFIG.setProperty("Hazelnutt.gui.lookAndFeel", laf.getClass().getName());

    // Load the frame
    LOGGER.trace("Launching main frame...");
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            SwingUtilities.updateComponentTreeUI(FRAME);
            FRAME.setVisible(true);
        }
    });
}

From source file:Main.java

/**
 * MacOS Look and feel test//from   w w  w .j a v  a 2  s .c o  m
 * @return true if using Aqua Look n' Feel
 */
public static boolean isAquaLookAndFeel() {
    return System.getProperty("mrj.version") != null && UIManager.getSystemLookAndFeelClassName()
            .equals(UIManager.getLookAndFeel().getClass().getName());
}

From source file:Main.java

public static void setLookAndFeel() {
    if (UIManager.getLookAndFeel().getID().equals("Aqua")) { //$NON-NLS-1$
        SPINNERHEIGHT = 20;//from www.j  a  va2  s  .  c o  m
    } else { // try to use Nimbus unless on Mac Os
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); //$NON-NLS-1$
        } catch (Exception e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
            } catch (InstantiationException e1) {
                e1.printStackTrace();
            } catch (IllegalAccessException e1) {
                e1.printStackTrace();
            } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
            }
        }
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Launch the application.// w  w w .  ja  va2s .c o m
 * 
 * @param args
 */
public static void main(String[] args) {
    StartSplashWindow splashWin = null;
    Thread tr = null;
    //
    // Kommandozeilenargumente parsen
    //
    try {
        if (!parseCliOptions(args)) {
            System.err.println("Error while scanning CLI-Args....");
            System.exit(-1);
        }
    } catch (Exception ex2) {
        System.err.println("Error while scanning CLI-Args....");
        System.err.println(ex2.getLocalizedMessage());
        System.exit(-1);
    }
    //
    // So, hier knnte ich splashen, alle "gefhrlichen" Sachen sind erledigt
    //
    splashWin = new StartSplashWindow();
    tr = new Thread(splashWin);
    tr.start();
    try {
        Thread.sleep(500);
    } catch (InterruptedException ex1) {
    }
    //
    // GUI starten
    //
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getLookAndFeel());
                // Set cross-platform Java L&F (also called "Metal")
                UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            } catch (UnsupportedLookAndFeelException ex) {
                System.out.print("fallback to standart look an feel..");
            } catch (ClassNotFoundException ex) {
                System.out.print("fallback to standart look an feel..");
            } catch (InstantiationException ex) {
                System.out.print("fallback to standart look an feel..");
            } catch (IllegalAccessException ex) {
                System.out.print("fallback to standart look an feel..");
            }
            try {
                //
                // das Mainobjekt erzeugen
                //
                MainCommGUI window = new MainCommGUI();
                window.frmMainWindow.setVisible(true);
            } catch (Exception e) {
                System.err.println("Exception: " + e.getLocalizedMessage() + "\n");
                e.printStackTrace();
            }
        }
    });
    splashWin.terminate();
}

From source file:Main.java

/**
 * With certain look and feels, namely windows with XP style, the focus of a toolbar button is already indicated (border changes) and the focus indicator should not be drawn: this fixes the visual rendering.
 * @param toolBarButton the tool bar button for which to adjust the focus state.
 *//*from  ww  w .ja v  a 2  s. c  o  m*/
public static void adjustToolbarButtonFocus(AbstractButton toolBarButton) {
    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    if (lookAndFeel.isNativeLookAndFeel() && System.getProperty("os.name").startsWith("Windows")
            && !Boolean.parseBoolean(System.getProperty("swing.noxp"))
            && !lookAndFeel.getClass().getName().endsWith("WindowsClassicLookAndFeel")) {
        toolBarButton.setFocusPainted(false);
    }
}