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:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void setPassword() {
    if (right != null && !right.isDisposed()) {
        right.dispose();/*from  w w w  .  ja  v a 2  s . c o  m*/
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";

    Frame runFrame = SWT_AWT.new_Frame(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    java.awt.Container oAwtContainer = runRoot.getContentPane();

    AdminToolSetPasswordJPanel runTreePanel = new AdminToolSetPasswordJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void setKey() {
    if (right != null && !right.isDisposed()) {
        right.dispose();//www .j  av a2s.c  o  m
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
    Frame runFrame = SWT_AWT.new_Frame(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    java.awt.Container oAwtContainer = runRoot.getContentPane();

    AdminToolSetKeyJPanel runTreePanel = new AdminToolSetKeyJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}

From source file:edu.stanford.muse.launcher.Splash.java

/** we need a system tray icon for management.
 * http://docs.oracle.com/javase/6/docs/api/java/awt/SystemTray.html */
public static void setupSystemTrayIcon() {
    // Set the app name in the menu bar for mac. 
    // c.f. http://stackoverflow.com/questions/8918826/java-os-x-lion-set-application-name-doesnt-work
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ePADD");
    try {/*from   w  ww . j  a va  2  s.c  om*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    TrayIcon trayIcon = null;
    if (SystemTray.isSupported()) {
        System.out.println("Adding ePADD to the system tray");
        SystemTray tray = SystemTray.getSystemTray();

        URL u = TomcatMain.class.getClassLoader().getResource("muse-icon.png"); // note: this better be 16x16, Windows doesn't resize! Mac os does.
        System.out.println("ePADD icon resource is " + u);
        Image image = Toolkit.getDefaultToolkit().getImage(u);
        System.out.println("Image = " + image);

        // create menu items and their listeners
        ActionListener openMuseControlsListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    launchBrowser(BASE_URL + "/info", null);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        };

        ActionListener QuitMuseListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                out.println("*** Received quit from system tray. Stopping the Tomcat embedded web server.");
                try {
                    shutdownSessions();
                    server.stop();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                System.exit(0); // we need to explicitly system.exit because we now use Swing (due to system tray, etc).
            }
        };

        // create a popup menu
        PopupMenu popup = new PopupMenu();
        MenuItem defaultItem = new MenuItem("Open ePADD window");
        defaultItem.addActionListener(openMuseControlsListener);
        popup.add(defaultItem);
        MenuItem quitItem = new MenuItem("Quit ePADD");
        quitItem.addActionListener(QuitMuseListener);
        popup.add(quitItem);

        /// ... add other items
        // construct a TrayIcon
        String message = "ePADD menu";
        // on windows - the tray menu is a little non-intuitive, needs a right click (plain click seems unused)
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0)
            message = "Right click for ePADD menu";
        trayIcon = new TrayIcon(image, message, popup);
        System.out.println("tray Icon = " + trayIcon);
        // set the TrayIcon properties
        //            trayIcon.addActionListener(openMuseControlsListener);
        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            err.println(e);
        }
        // ...
    } else {
        // disable tray option in your application or
        // perform other actions
        //            ...
    }
    System.out.println("Done!");
    // ...
    // some time later
    // the application state has changed - update the image
    if (trayIcon != null) {
        //        trayIcon.setImage(updatedImage);
    }
    // ...
}

From source file:gui.TheGui.java

/**
 * @param args the command line arguments
 *//* w  ww  .j a  v  a2 s .c  o m*/
public static void main(String args[]) {
    try {
        /*
         * 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
         */
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        //                if ("Nimbus".equals(info.getName())) {
        //                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
        //                }
        //                }
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    }

    //</editor-fold>

    /*
     * Create and display the form
     */
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            new TheGui().setVisible(true);
        }
    });
}

From source file:GroupProject.OriginalChartUI.java

/**
 * The entrance of the original data display page
 * @param args the command line arguments
 * @throws java.lang.ClassNotFoundException
 * @throws java.lang.InstantiationException
 * @throws java.lang.IllegalAccessException
 * @throws javax.swing.UnsupportedLookAndFeelException
 *//*from  w  ww .j a  va2s  .c om*/
public static void main(String args[]) throws ClassNotFoundException, InstantiationException,
        UnsupportedLookAndFeelException, IllegalAccessException {
    UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
    /* 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 {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Sea".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(DMChartUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(DMChartUI.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(DMChartUI.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 OriginalChartUI().setVisible(true);

        }
    });
}

From source file:jchrest.gui.Shell.java

/**
 * Set theme of user interface to the one named.
 */// w  w w  .  j  a va2  s.c o  m
private void setTheme(String theme) {
    try {
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if (theme.equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (UnsupportedLookAndFeelException e) {
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    }
    // make sure all components are updated
    SwingUtilities.updateComponentTreeUI(this);
    // SwingUtilities.updateComponentTreeUI(_fileChooser); TODO: update FileUtilities filechooser
}

From source file:gui.TheGui.java

/**
 * @param args the command line arguments
 *//*from w  w w. j a va  2 s .  c o m*/
public static void main(String args[]) {
    try {
        /*
         * 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
         */
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        //                if ("Nimbus".equals(info.getName())) {
        //                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
        //                }
        //                }
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(TheGui.class.getName()).log(Level.SEVERE, null, ex);
    }

    //</editor-fold>

    /*
     * Create and display the form
     */
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            new TheGui().setVisible(true);
        }
    });
}

From source file:UserInfo_Frame.java

/**
 * @param args the command line arguments
 *///w  w w  .j a 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 {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            /*  if ("Nimbus".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
              }*/
            // select Look and Feel of Jtattoo
            UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(UserInfo_Frame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(UserInfo_Frame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(UserInfo_Frame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(UserInfo_Frame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>

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

From source file:edu.stanford.epadd.launcher.Splash.java

/** we need a system tray icon for management.
 * http://docs.oracle.com/javase/6/docs/api/java/awt/SystemTray.html */
public static void setupSystemTrayIcon() {
    // Set the app name in the menu bar for mac. 
    // c.f. http://stackoverflow.com/questions/8918826/java-os-x-lion-set-application-name-doesnt-work
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ePADD");
    try {/*from   w w w  .ja  v a2  s.c  o m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    TrayIcon trayIcon = null;
    if (SystemTray.isSupported()) {
        System.out.println("Adding ePADD to the system tray");
        SystemTray tray = SystemTray.getSystemTray();

        URL u = TomcatMain.class.getClassLoader().getResource("muse-icon.png"); // note: this better be 16x16, Windows doesn't resize! Mac os does.
        System.out.println("ePADD icon resource is " + u);
        Image image = Toolkit.getDefaultToolkit().getImage(u);
        System.out.println("Image = " + image);

        // create menu items and their listeners
        ActionListener openMuseControlsListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    launchBrowser(BASE_URL, null); // no + "info" for epadd like in muse
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        };

        ActionListener QuitMuseListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                out.println("*** Received quit from system tray. Stopping the Tomcat embedded web server.");
                try {
                    shutdownSessions();
                    server.stop();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                System.exit(0); // we need to explicitly system.exit because we now use Swing (due to system tray, etc).
            }
        };

        // create a popup menu
        PopupMenu popup = new PopupMenu();
        MenuItem defaultItem = new MenuItem("Open ePADD window");
        defaultItem.addActionListener(openMuseControlsListener);
        popup.add(defaultItem);
        MenuItem quitItem = new MenuItem("Quit ePADD");
        quitItem.addActionListener(QuitMuseListener);
        popup.add(quitItem);

        /// ... add other items
        // construct a TrayIcon
        String message = "ePADD menu";
        // on windows - the tray menu is a little non-intuitive, needs a right click (plain click seems unused)
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0)
            message = "Right click for ePADD menu";
        trayIcon = new TrayIcon(image, message, popup);
        System.out.println("tray Icon = " + trayIcon);
        // set the TrayIcon properties
        //            trayIcon.addActionListener(openMuseControlsListener);
        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            out.println(e);
        }
        // ...
    } else {
        // disable tray option in your application or
        // perform other actions
        //            ...
    }
    System.out.println("Done!");
    // ...
    // some time later
    // the application state has changed - update the image
    if (trayIcon != null) {
        //        trayIcon.setImage(updatedImage);
    }
    // ...
}

From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.views.PatientCountView.java

private void audit() {
    //System.out.println(item.getText()+" item selected");
    //group.setVisible(false);
    //composite1.setVisible(true);
    if (right != null && !right.isDisposed()) {
        right.dispose();//www  .j  a  v a  2 s  .c om
        right = null;
    }

    right = new Composite(composite, SWT.NONE);
    GridLayout rightLayout1 = new GridLayout();
    GridData rightLData = new GridData();
    rightLData.grabExcessHorizontalSpace = true;
    rightLData.grabExcessVerticalSpace = true;
    rightLData.horizontalAlignment = GridData.FILL;
    rightLData.verticalAlignment = GridData.FILL;
    right.setLayoutData(rightLData);
    right.setLayout(rightLayout1);
    GridData composite1LData = new GridData();
    composite1LData.grabExcessHorizontalSpace = true;
    composite1LData.grabExcessVerticalSpace = true;
    composite1LData.horizontalAlignment = GridData.FILL;
    composite1LData.verticalAlignment = GridData.FILL;

    composite1 = new Composite(right, SWT.EMBEDDED);
    composite1.setLayoutData(composite1LData);

    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //   SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";   
    Frame runFrame = SWT_AWT.new_Frame(composite1);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e1) {
        System.out.println("Error setting native LAF: " + e1);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    java.awt.Container oAwtContainer = runRoot.getContentPane();

    AdminToolMonitorJPanel runTreePanel = new AdminToolMonitorJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);
    //oAwtContainer.setVisible(true);
    //oAwtContainer.setSize(500, 500);

    //right.layout(true);
    //right.setVisible(true);
    //right.update();

    composite.layout(true);
    //composite.setVisible(true);
    //composite.update();
}