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:MDIApp.java
/************************************************************************* * METHODS/* w w w .j av a2 s . c om*/ *************************************************************************/ public MDIApp() { super("Java Media Player"); // Add the desktop pane setLayout(new BorderLayout()); desktop = new JDesktopPane(); desktop.setDoubleBuffered(true); add("Center", desktop); setMenuBar(createMenuBar()); setSize(640, 480); setVisible(true); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { System.err.println("Could not initialize java.awt Metal lnf"); } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true)); }
From source file:misc.TablePrintDemo1.java
/** * Start the application.// w w w .ja va2s . c om */ public static void main(final String[] args) { /* Schedule for the GUI to be created and shown on the EDT */ SwingUtilities.invokeLater(new Runnable() { public void run() { /* Don't want bold fonts if we end up using metal */ UIManager.put("swing.boldMetal", false); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } new TablePrintDemo1().setVisible(true); } }); }
From source file:org.pentaho.aggdes.ui.UIMain.java
private void setLAF() { try {//from w w w . j a va2s . c om String laf = configuration.getLookAndFeel(); if (laf.equalsIgnoreCase("system")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else if (laf.equalsIgnoreCase("metal")) { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } else if (!StringUtils.isEmpty(laf)) { UIManager.setLookAndFeel(laf); } else { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } } catch (Exception e) { logger.warn("error setting look and feel", e); //$NON-NLS-1$ } }
From source file:LookAndFeelDemo.java
private static void initLookAndFeel() { String lookAndFeel = null;/* ww w . j av a 2 s. c om*/ 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:ca.osmcanada.osvuploadr.JPMain.java
/** * Creates new form JPMain/*from w w w.ja v a 2 s .c o m*/ */ public JPMain(Locale locale) { l = locale; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { } initComponents(); try { r = ResourceBundle.getBundle("Bundle", l); } catch (Exception ex) { System.out.println(ex.toString()); } SetUILang(); }
From source file:com.alvermont.terraj.util.ui.LookAndFeelUtils.java
/** * Change the look and feel to either the native one or the cross * platform Java one/*from ww w. jav a 2 s . c om*/ * * @param wantSystem If <pre>true</pre> then we are selecting the native * look and feel * @param topLevel The top level component for the main frame * @return <pre>true</pre> if the look and feel was successfully changed */ public boolean setSystemLookAndFeel(boolean wantSystem, Window topLevel) { boolean ok = true; try { if (wantSystem) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } SwingUtilities.updateComponentTreeUI(topLevel); topLevel.pack(); final LookAndFeelChangedEvent event = new LookAndFeelChangedEvent(this); fireLookAndFeelChangedEventListenerHandleLookAndFeelChangedEvent(event); } catch (UnsupportedLookAndFeelException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (ClassNotFoundException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (IllegalAccessException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (InstantiationException ex) { log.error("Failed to set LAF", ex); ok = false; } return ok; }
From source file:se.sics.kompics.p2p.monitor.cyclon.server.CyclonMonitorServer.java
public CyclonMonitorServer(CyclonMonitorServerInit init) { this.view = new HashMap<OverlayAddress, OverlayViewEntry>(); this.alivePeers = new TreeMap<OverlayAddress, CyclonNeighbors>(); this.deadPeers = new TreeMap<OverlayAddress, CyclonNeighbors>(); this.outstandingTimeouts = new HashSet<UUID>(); subscribe(handleWebRequest, web);// w ww. j a v a2s. c o m subscribe(handlePeerNotification, network); subscribe(handleViewEvictPeer, timer); // INIT evictAfter = init.getConfiguration().getViewEvictAfter(); logger.debug("INIT"); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } }
From source file:lookandfeel.SynthDialog.java
private static void initLookAndFeel() { SynthLookAndFeel lookAndFeel = new SynthLookAndFeel(); //from ww w . j a va2 s . c o m try { // SynthLookAndFeel load() method throws a checked exception // (java.text.ParseException) so it must be handled lookAndFeel.load(SynthDialog.class.getResourceAsStream("synthDemo.xml"), SynthDialog.class); UIManager.setLookAndFeel(lookAndFeel); } 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:ch.zhaw.iamp.rct.Controller.java
private void configureGuiToolkit() { String operatingSystem = System.getProperty("os.name").toLowerCase(); boolean isUnix = operatingSystem.contains("nix") || operatingSystem.contains("nux") || operatingSystem.contains("aix"); try {//from w w w.j a v a 2 s .c o m if (isUnix) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (UnsupportedLookAndFeelException | ClassNotFoundException | IllegalAccessException | InstantiationException ex) { throw new IllegalStateException("The Look&Feel could not be configured correctly: " + ex.getMessage()); } }
From source file:ShowComponent.java
/** * This static method queries the system to find out what Pluggable * Look-and-Feel (PLAF) implementations are available. Then it creates a * JMenu component that lists each of the implementations by name and allows * the user to select one of them using JRadioButtonMenuItem components. * When the user selects one, the selected menu item traverses the component * hierarchy and tells all components to use the new PLAF. */// ww w.jav a2s . c om public static JMenu createPlafMenu(final JFrame frame) { // Create the menu 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(); // 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 JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName)); // Tell the menu item what to do when it is selected item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Set the new look and feel UIManager.setLookAndFeel(plafClassName); // Tell each component to change its look-and-feel SwingUtilities.updateComponentTreeUI(frame); // Tell the frame to resize itself to the its // children's new desired sizes frame.pack(); } catch (Exception ex) { System.err.println(ex); } } }); // Only allow one menu item to be selected at once radiogroup.add(item); } return plafmenu; }