List of usage examples for javax.swing UIManager setLookAndFeel
@SuppressWarnings("deprecation") public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
From source file:LookAndFeelPrefs.java
/** * Create a menu of radio buttons listing the available Look and Feels. When * the user selects one, change the component hierarchy under frame to the new * LAF, and store the new selection as the current preference for the package * containing class c./*from w ww . j av a 2s . c o m*/ */ public static JMenu createLookAndFeelMenu(final Class prefsClass, final ActionListener listener) { // Create the menu final JMenu plafmenu = new JMenu("Look and Feel"); // Create an object used for radio button mutual exclusion ButtonGroup radiogroup = new ButtonGroup(); // Look up the available look and feels UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); // Find out which one is currently used String currentLAFName = UIManager.getLookAndFeel().getClass().getName(); // Loop through the plafs, and add a menu item for each one for (int i = 0; i < plafs.length; i++) { String plafName = plafs[i].getName(); final String plafClassName = plafs[i].getClassName(); // Create the menu item final JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName)); item.setSelected(plafClassName.equals(currentLAFName)); // Tell the menu item what to do when it is selected item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // Set the new look and feel try { UIManager.setLookAndFeel(plafClassName); } catch (UnsupportedLookAndFeelException e) { // Sometimes a Look-and-Feel is installed but not // supported, as in the Windows LaF on Linux platforms. JOptionPane.showMessageDialog(plafmenu, "The selected Look-and-Feel is " + "not supported on this platform.", "Unsupported Look And Feel", JOptionPane.ERROR_MESSAGE); item.setEnabled(false); } catch (Exception e) { // ClassNotFound or Instantiation item.setEnabled(false); // shouldn't happen } // Make the selection persistent by storing it in prefs. Preferences p = Preferences.userNodeForPackage(prefsClass); p.put(PREF_NAME, plafClassName); // Invoke the supplied action listener so the calling // application can update its components to the new LAF // Reuse the event that was passed here. listener.actionPerformed(event); } }); // Only allow one menu item to be selected at once radiogroup.add(item); } return plafmenu; }
From source file:chibi.gemmaanalysis.cli.deprecated.ProbeMapperGui.java
/** * @param args//from ww w .j ava2s . co m */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } ProbeMapperGui pgmg = new ProbeMapperGui(); pgmg.pack(); pgmg.setVisible(true); }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
/** * Launch the application./*from ww w . ja v a2s. c o m*/ */ public static void main(final String[] args) { File baseDir = new File(System.getProperty("basedir", ".")); final Injector inj = Guice.createInjector(new AppModule(baseDir)); final ConfigController configCtrl = inj.getInstance(ConfigController.class); try { UIManager.setLookAndFeel(configCtrl.getLookAndFeelClassName()); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } ExceptionHandler exceptionHandler = inj.getInstance(ExceptionHandler.class); Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // This is necessary because an UncaughtExceptionHandler does not work in modal dialogs System.setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName()); EventQueue.invokeLater(new Runnable() { @Override public void run() { try { AppFrame frame = inj.getInstance(AppFrame.class); Rectangle bounds = configCtrl.getFrameBounds(); if (bounds != null) { frame.setBounds(bounds); } ImageIcon icon = new ImageIcon( getResource("com/mgmtp/perfload/loadprofiles/ui/perfLoad_Logo_bild_64x64.png")); frame.setIconImage(icon.getImage()); frame.updateLists(); frame.updateGraph(); frame.addTableListeners(); frame.setUpEventBus(); frame.setExtendedState(configCtrl.getFrameState()); frame.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); } } }); }
From source file:com.github.cmisbox.ui.UI.java
private UI() { this.log = LogFactory.getLog(this.getClass()); try {/* ww w .jav a2 s .co m*/ this.available = !GraphicsEnvironment.isHeadless(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (SystemTray.isSupported()) { this.tray = SystemTray.getSystemTray(); Image image = ImageIO.read(this.getClass().getResource("images/cmisbox.png")); ActionListener exitListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Main.exit(0); } }; this.popup = new PopupMenu(); MenuItem defaultItem = new MenuItem(Messages.exit); defaultItem.addActionListener(exitListener); this.popup.add(defaultItem); MenuItem loginItem = new MenuItem(Messages.login); loginItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new LoginDialog(); } }); this.popup.add(loginItem); MenuItem treeItem = new MenuItem(Messages.showTree); treeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new TreeSelect(); } }); this.popup.add(treeItem); final TrayIcon trayIcon = new TrayIcon(image, UI.NOTIFY_TITLE, this.popup); trayIcon.setImageAutoSize(true); this.tray.add(trayIcon); this.notify(Messages.startupComplete); } } catch (Exception e) { this.log.error(e); } }
From source file:net.sf.translate64.util.TranslateUtils.java
/** * Set the native look and feel./*from w w w .ja v a 2 s.c om*/ */ public static void setNativeLookAndFeel() { // let's try try { // set the default look and feel as the system look and feel UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // something happened, but do nothing } }
From source file:item.analysis.report.MainFrame.java
/** * @param args the command line arguments *///from w w w .j av a 2 s . 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 { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainFrame.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 MainFrame().setVisible(true); } }); }
From source file:com.awesomecoding.minetestlauncher.Main.java
private void initialize() { fileGetter = new FileGetter(userhome + "\\minetest\\temp\\"); latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true); currentVersion = latest.split("\n")[0]; changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false); try {/* w w w .j a v a2 s . co m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } frmMinetestLauncherV = new JFrame(); frmMinetestLauncherV.setResizable(false); frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit() .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png"))); frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)"); frmMinetestLauncherV.setBounds(100, 100, 720, 480); frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpringLayout springLayout = new SpringLayout(); frmMinetestLauncherV.getContentPane().setLayout(springLayout); final JProgressBar progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(progressBar); final JButton btnDownloadPlay = new JButton("Play!"); springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar); springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(btnDownloadPlay); final JLabel label = new JLabel("Ready to play!"); springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label); springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label); frmMinetestLauncherV.getContentPane().add(label); JTextPane txtpnNewFeatures = new JTextPane(); txtpnNewFeatures.setBackground(SystemColor.window); springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay); springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay); txtpnNewFeatures.setEditable(false); txtpnNewFeatures.setContentType("text/html"); txtpnNewFeatures.setText(changelog); txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures); File file = new File(userhome + "\\minetest\\version.txt"); if (!file.exists()) newVersion = true; else { String version = fileGetter.getLocalContents(file, false); if (!version.equals(currentVersion)) newVersion = true; } if (newVersion) { label.setText("New Version Available! (" + currentVersion + ")"); btnDownloadPlay.setText("Download & Play"); btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Thread t = new Thread() { public void run() { File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); try { FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version)); } catch (Exception e) { e.printStackTrace(); } fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\", "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion); try { label.setText("Cleaning up..."); btnDownloadPlay.setText("Cleaning up..."); FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp")); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } }; t.start(); } }); } else { btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { label.setText("Launching..."); btnDownloadPlay.setEnabled(false); btnDownloadPlay.setText("Launching..."); File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); Runtime.getRuntime() .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe"); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } }); progressBar.setValue(100); } }
From source file:ca.sfu.federation.Application.java
/** * Start the application./* w ww. j a v a2 s . c om*/ */ @Override public void run() { logger.log(Level.INFO, "Starting application"); // set the look and feel options try { logger.log(Level.FINE, "Setting look and feel options"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JPopupMenu.setDefaultLightWeightPopupEnabled(false); LookAndFeelUtil.removeAllSplitPaneBorders(); } catch (Exception e) { String stack = ExceptionUtils.getFullStackTrace(e); logger.log(Level.WARNING, "Could not set look and feel options\n\n{0}", stack); } // create the main application frame logger.log(Level.FINE, "Creating main application frame"); frame = new ApplicationFrame(); // show the application frame.setVisible(true); }
From source file:CascadeDemo.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == m_newFrame) newFrame();//from ww w . j a v a 2 s .com else if (e.getSource() == m_UIBox) { m_UIBox.hidePopup(); // BUG WORKAROUND try { UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception ex) { System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName()); } } }
From source file:com.haulmont.cuba.desktop.theme.impl.DesktopThemeImpl.java
@Override public void init() { JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); try {//from w ww . j ava 2s . co m UIManager.setLookAndFeel(lookAndFeel); initUIDefaults(); initButtonsKeyBinding(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { throw new RuntimeException(e); } if (marginSize != null) { UnitValue marginValue = new UnitValue(marginSize); PlatformDefaults.setPanelInsets(marginValue, marginValue, marginValue, marginValue); } if (spacingSize != null) { UnitValue spacingValue = new UnitValue(spacingSize); PlatformDefaults.setGridCellGap(spacingValue, spacingValue); } }