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:marytts.tools.redstart.AdminWindow.java

/** Sets the GUI look and feel to that of the system (e.g., Windows XP, Mac OS) */
private void setSystemLookAndFeel() {

    // Get the properties from the options file
    Properties options = new Properties();
    try {/*from  w  w w  .j  ava 2 s.c  o m*/
        // First, load defaults from resource in classpath:
        options.load(Redstart.class.getResourceAsStream("user.options"));

        // Then, overwrite from file if present:
        File fileHandle = new File(optionsDialog.getOptionsPathString());
        if (fileHandle.exists()) {
            FileInputStream optionsStream;
            try {
                optionsStream = new FileInputStream(fileHandle);
                options.load(optionsStream);

                // Close the input stream
                optionsStream.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    String systemLookAndFeelProp = options.getProperty("systemLookAndFeel");

    if (systemLookAndFeelProp.equals("true")) {

        // Use the look and feel of the system
        try {
            // Set to system look and feel
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        }

    }
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

/**
 * @param args the command line arguments
 *//* w w  w  .  j  a v  a2  s .co  m*/
public static void main(String args[]) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        //
    }
    Logger.getRootLogger().setLevel(Level.ALL);
    Logger.getRootLogger()
            .addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
    PropertyPrinter.main(new String[] {});
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new MainFrame().setVisible(true);
        }
    });
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>/*w  w  w .j  a  v  a2 s.co m*/
 * platformLookAndFeel</p>
 */
public void platformLookAndFeel() {
    try {
        if (SystemUtils.IS_OS_LINUX) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        logger.log(Level.WARNING, "Can''t set look and feel: {0}", e);
    }
}

From source file:forms.frDados.java

/**
 * Aplica um tema s janelas da aplicao.//from w w w. j  a v a 2  s.  c om
 * @param e Evento do menu de temas.
 */
@Override
public void actionPerformed(ActionEvent e) {

    if (e.getSource() instanceof JMenuItem) {
        String name = ((JMenuItem) e.getSource()).getText();

        try {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if (info.getName().equals(name))
                    UIManager.setLookAndFeel(info.getClassName());
                SwingUtilities.updateComponentTreeUI(this);
                SwingUtilities.updateComponentTreeUI(jfcArquivo);
                SwingUtilities.updateComponentTreeUI(frCadastro);
            }

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException ex) {
            Logger.getLogger(frDados.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:edu.ku.brc.specify.conversion.ConvertVerifier.java

/**
 * @param args//from  w ww. ja  v a 2s .  c o m
 */
public static void main(String[] args) {

    UIRegistry.setAppName("Specify");
    AppBase.processArgs(args);

    // Create Specify Application
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                if (!System.getProperty("os.name").equals("Mac OS X")) {
                    UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
                    PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                }
            } catch (Exception e) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConvertVerifier.class, e);
                log.error("Can't change L&F: ", e);
            }

            final ConvertVerifier cv = new ConvertVerifier();

            if (cv.selectedDBsToConvert()) {
                try {
                    final Pair<String, String> pair = cv.chooseTable();
                    if (pair != null) {
                        SwingWorker workerThread = new SwingWorker() {
                            @Override
                            public Object construct() {
                                try {
                                    boolean compareTo6DBS = false;
                                    if (compareTo6DBS) {
                                        pair.first = "ku_fish";
                                        pair.second = "kui_fish_dbo_6";
                                        cv.setCompareTo6DBs(compareTo6DBS);
                                    }

                                    cv.verifyDB(pair.first, pair.second);

                                } catch (Exception ex) {
                                    ex.printStackTrace();
                                }
                                return null;
                            }

                            @Override
                            public void finished() {
                            }
                        };

                        // start the background task
                        workerThread.start();

                    } else {
                        JOptionPane.showMessageDialog(null, "The ConvertVerifier was unable to login",
                                "Not Logged In", JOptionPane.ERROR_MESSAGE);
                        System.exit(0);
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    System.exit(0);
                }
            }

        }
    });

}

From source file:jeplus.JEPlusFrameMain.java

private void jMenuItemDefaultLaFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDefaultLaFActionPerformed
    try {/*  w  w  w .j a  v a2 s.com*/
        switch (jMenuItemDefaultLaF.getActionCommand()) {
        case "default":
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            SwingUtilities.updateComponentTreeUI(this);
            jMenuItemDefaultLaF.setActionCommand("platform");
            jMenuItemDefaultLaF.setText("Switch to system Look and Feel (OS)");
            this.pack();
            break;
        case "platform":
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(this);
            jMenuItemDefaultLaF.setActionCommand("default");
            jMenuItemDefaultLaF.setText("Switch to defaul Look and Feel (Metal)");
            this.pack();
            break;
        }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        logger.error("Error setting Look-and-Feel.", ex);
    }
}

From source file:edu.ku.brc.specify.Specify.java

/**
 *
 *//*from   w w  w  . j a  v a  2 s  . co m*/
public static void main(String[] args) {

    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    //log.debug("********* Current ["+(new File(".").getAbsolutePath())+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    //UIHelper.attachUnhandledException();

    SwingUtilities.invokeLater(new Runnable() {
        @SuppressWarnings("synthetic-access") //$NON-NLS-1$
        public void run() {
            log.debug("Checking for update....");
            try {
                try {
                    UIHelper.OSTYPE osType = UIHelper.getOSType();
                    if (osType == UIHelper.OSTYPE.Windows) {
                        //UIManager.setLookAndFeel(new WindowsLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());

                    } else if (osType == UIHelper.OSTYPE.Linux) {
                        //UIManager.setLookAndFeel(new GTKLookAndFeel());
                        UIManager.setLookAndFeel(new PlasticLookAndFeel());
                        //PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
                        //PlasticLookAndFeel.setPlasticTheme(new DesertGreen());

                    } else {
                        //PlafOptions.setAsLookAndFeel();
                    }
                } catch (Exception e) {
                    log.error("Can't change L&F: ", e); //$NON-NLS-1$
                }

                // Load Local Prefs
                AppPreferences localPrefs = AppPreferences.getLocalPrefs();
                localPrefs.setDirPath(UIRegistry.getAppDataDir());

                ProxyHelper.setProxySettingsFromPrefs();

                checkDebugLoggerSettings();

                //log.error("LocalPrefs: "+(new File(UIRegistry.getAppDataDir())).getCanonicalPath());

                // Check to see if we should check for a new version
                String VERSION_CHECK = "version_check.auto";
                if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
                    localPrefs.putBoolean(VERSION_CHECK, true);
                }

                // For Proxies
                boolean isOKToGetSpecialMsgs = AppPreferences.getLocalPrefs().getBoolean("GET_SPECIAL_MSGS",
                        true);
                if (isOKToGetSpecialMsgs) {
                    SpecialMsgNotifier smn = new SpecialMsgNotifier();
                    smn.checkForMessages();
                }

                if (UIRegistry.isEmbedded() && !UIRegistry.isMobile()) {
                    String EZDB_FIRSTTIME = "ezdb.firsttime";
                    if (localPrefs.getBoolean(EZDB_FIRSTTIME, null) == null) {
                        UIRegistry.showLocalizedMsg("EZDB_FIRSTTIME");
                        localPrefs.putBoolean(EZDB_FIRSTTIME, true);
                        localPrefs.flush();
                    }
                }

                String EXTRA_CHECK = "extra.check";
                Boolean isExtraCheck = localPrefs.getBoolean(EXTRA_CHECK, true);
                if (isExtraCheck == null) {
                    isExtraCheck = true;
                    localPrefs.putBoolean(EXTRA_CHECK, isExtraCheck);
                }

                // Managed Releases
                // it's never managed for the Release Manager
                //                  boolean isReleaseManager = localPrefs.getBoolean("RELEASE_MANAGER", false);
                //                  boolean isManagedRelease = localPrefs.getBoolean(MANAGED_RELEASES, false);
                //                  boolean isMgrRel         = !isReleaseManager && isManagedRelease;
                //
                //                  // Never check if it is a managed release
                //                  boolean verChk = localPrefs.getBoolean(VERSION_CHECK, true);
                //                  if (localPrefs.getBoolean(VERSION_CHECK, true) && !isMgrRel)
                //                  {
                //                      if (!isMgrRel)
                //                      {
                //                          localPrefs.getBoolean(MANAGED_RELEASES, false); // remove it in case it was turned on
                //                      }

                //                      try
                //                      {
                //                        com.install4j.api.launcher.SplashScreen.hide();
                //                         ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback()
                //                         {
                //                             @Override
                //                             public void exited(int exitValue)
                //                             {
                //                                 startApp();
                //                             }
                //                             
                //                             @Override
                //                             public void prepareShutdown()
                //                             {
                //                                 
                //                             }
                //                          };
                //                          //ApplicationLauncher.launchApplication("100", getProxySettings(), true, callback);
                //                          
                //                      } catch (Exception ex)
                //                      {
                //                          //ex.printStackTrace();
                //                          log.error(ex);
                //                          startApp();
                //                      }
                //                  } else
                //                  {
                //                      if (!isExtraCheck && StringUtils.isNotEmpty(UIRegistry.getAppVersion()))
                //                      {
                //                          UIRegistry.showLocalizedMsg(null, "SpReg.NOT_REGISTERED");
                //                      }
                startApp();
                //                  }
            } catch (Exception ex) {
                ex.printStackTrace();
                log.error(ex);
            }
        }
    });

}

From source file:base.BasePlayer.Main.java

public static void main(String[] args) {
    try {// w  ww.  j  a va  2 s.c  om
        UIManager.put("Slider.paintValue", false);
        //   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        System.setProperty("sun.java2d.d3d", "false");
    } catch (Exception e) {
        e.printStackTrace();
    }
    Main.args = args;
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            //Logo.main(argsit);
            createAndShowGUI();
        }
    });
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

public static void main(String[] args) {
    Logger.getRootLogger().addAppender(
            new ConsoleAppender(new org.apache.log4j.PatternLayout("%d - %-5p - %-20c (%C [%L]) - %m%n")));

    GlobalOptions.setSelectedServer("de43");
    DataHolder.getSingleton().loadData(false);
    ProfileManager.getSingleton().loadProfiles();
    GlobalOptions.setSelectedProfile(ProfileManager.getSingleton().getProfiles("de43")[0]);
    TroopsManager.getSingleton().initialize();
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {

            MouseGestures mMouseGestures = new MouseGestures();
            mMouseGestures.setMouseButton(MouseEvent.BUTTON3_MASK);
            mMouseGestures.addMouseGesturesListener(new MouseGestureHandler());
            mMouseGestures.start();/*from   w  w  w.jav  a  2s.  c o  m*/
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                //  UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                //JFrame.setDefaultLookAndFeelDecorated(true);

                // SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel.getAllSkins().get("Twilight").getClassName());
                //  UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE);
            } catch (Exception e) {
            }
            Logger.getRootLogger().addAppender(new ConsoleAppender(
                    new org.apache.log4j.PatternLayout("%d - %-5p - %-20c (%C [%L]) - %m%n")));

            TribeTribeAttackFrame f = new TribeTribeAttackFrame();
            f.setup();
            f.setSize(600, 400);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
        }
    });
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes windowsItem/*from  w ww .  j  a v  a2 s. c om*/
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getWindowsMenuItem() {
    if (windowsMenuItem == null) {
        windowsMenuItem = new JMenuItem();
        windowsMenuItem.setText("Windows");
        windowsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                    SwingUtilities.updateComponentTreeUI(instance);
                    itSettings.getChild("generalSettings").getChild("graphics").getChild("appearence")
                            .setText("Windows");
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
    }
    return windowsMenuItem;
}