Example usage for javax.swing UIManager getCrossPlatformLookAndFeelClassName

List of usage examples for javax.swing UIManager getCrossPlatformLookAndFeelClassName

Introduction

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

Prototype

public static String getCrossPlatformLookAndFeelClassName() 

Source Link

Document

Returns the name of the LookAndFeel class that implements the default cross platform look and feel -- the Java Look and Feel (JLF).

Usage

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

/**Main method for starting the application.
 * /*from   w ww  .j a  v a 2s  .  c om*/
 * @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:Main.java

public static void setLookAndFeelToDefault() {
    try {//from   w w w  .j  a  va 2  s  . com
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        e.printStackTrace();
    }
}

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

/**
 * Launch the application./*from w  ww . j  ava 2  s.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

static void setSwingLAF(java.awt.Component comp, String targetTheme) {

    try {// ww w .  j  a  v a 2 s  . c o  m
        if (targetTheme.equalsIgnoreCase(Native)) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else if (targetTheme.equalsIgnoreCase(Java)) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } else if (targetTheme.equalsIgnoreCase(Motif)) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        }

        //            if (targetTheme.equalsIgnoreCase(plaf)){
        //                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        //            }
        //
        //            if (targetTheme.equalsIgnoreCase(GTK)){
        //                UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        //            }
        SwingUtilities.updateComponentTreeUI(comp);

        if (comp instanceof java.awt.Frame) {
            ((java.awt.Frame) comp).pack();
        }
    } catch (Exception e) {
        errorMessage(e);
    }
}

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

public static void setJavaLookAndFeel() {
    try {/*  ww w . java  2s .c  o m*/
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Unable to set Java Look and Feel.", e);
    }

    JFrame.setDefaultLookAndFeelDecorated(true);
}

From source file:hr.fer.zemris.vhdllab.platform.support.OSBasedUIManagerConfigurer.java

@Override
protected void doInstallCustomDefaults() throws Exception {
    if (System.getProperty("os.name").equals("Linux")) {
        try {//from   w ww . j  a  v  a  2s.co m
            installJGoodiesLooks();
        } catch (UnsupportedLookAndFeelException e) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            UIManager.put("swing.boldMetal", Boolean.FALSE);
        }
    } else {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
}

From source file:de.uzk.hki.da.sb.SIPBuilder.java

/**
 * Starts the SIP-Builder in GUI mode//www.ja  v a  2  s .  c  o  m
 * 
 * @param confFolderPath Path to conf folder
 * @param dataFolderPath Path to data folder
 */
private static void startGUIMode(String confFolderPath, String dataFolderPath) {

    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        return;
    }

    UIManager.put("Label.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("ComboBox.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("CheckBox.disabledText", Color.LIGHT_GRAY);

    Gui gui = new Gui(confFolderPath, dataFolderPath);
    gui.setBounds(100, 100, 750, 520);
    gui.setResizable(false);
    gui.setVisible(true);
    gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    gui.setTitle("DA NRW SIP-Builder");
}

From source file:OAT.ui.util.UiUtil.java

public static void useCrossPlatformLookAndFeel(Component object) {
    String laf;/* w w w . j  a v a2 s .  c  o m*/
    boolean useNative = false;

    if (useNative) {
        laf = UIManager.getSystemLookAndFeelClassName();
    } else {
        laf = UIManager.getCrossPlatformLookAndFeelClassName();
    }

    try {
        UIManager.setLookAndFeel(laf);
        SwingUtilities.updateComponentTreeUI(object);
    } catch (Exception e) {
        System.err.println("Couldn't use the " + laf + "look and feel: " + e);
    }
}

From source file:lookandfeel.LookAndFeelDemo.java

private static void initLookAndFeel() {
    String lookAndFeel = null;// www  .  java  2  s  .  c  o m

    if (LOOKANDFEEL != null) {
        if (LOOKANDFEEL.equals("Metal")) {
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
            //  an alternative way to set the Metal L&F is to replace the 
            // previous line with:
            // lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";

        }

        else if (LOOKANDFEEL.equals("System")) {
            lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        }

        else if (LOOKANDFEEL.equals("Motif")) {
            lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        }

        else if (LOOKANDFEEL.equals("GTK")) {
            lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        }

        else {
            System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        }

        try {

            UIManager.setLookAndFeel(lookAndFeel);

            // If L&F = "Metal", set the theme

            if (LOOKANDFEEL.equals("Metal")) {
                if (THEME.equals("DefaultMetal"))
                    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
                else if (THEME.equals("Ocean"))
                    MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                else
                    MetalLookAndFeel.setCurrentTheme(new TestTheme());

                UIManager.setLookAndFeel(new MetalLookAndFeel());
            }

        }

        catch (ClassNotFoundException e) {
            System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel);
            System.err.println("Did you include the L&F library in the class path?");
            System.err.println("Using the default look and feel.");
        }

        catch (UnsupportedLookAndFeelException e) {
            System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform.");
            System.err.println("Using the default look and feel.");
        }

        catch (Exception e) {
            System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
            System.err.println("Using the default look and feel.");
            e.printStackTrace();
        }
    }
}

From source file:de.uzk.hki.da.main.SIPBuilder.java

/**
 * Starts the SIP-Builder in GUI mode/*from w w w.java2s  . c o  m*/
 * 
 * @param confFolderPath Path to conf folder
 * @param dataFolderPath Path to data folder
 */
private static void startGUIMode(String confFolderPath, String dataFolderPath) {

    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
        return;
    }

    UIManager.put("Label.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("ComboBox.disabledForeground", Color.LIGHT_GRAY);
    UIManager.put("CheckBox.disabledText", Color.LIGHT_GRAY);

    Gui gui = new Gui(confFolderPath, dataFolderPath);
    gui.setBounds(100, 100, 750, 520);
    gui.setResizable(false);
    gui.setVisible(true);
    gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    gui.setTitle(getProperties().getProperty("ARCHIVE_NAME") + " SIP-Builder");
}