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:edu.stanford.epadd.launcher.Main.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 {// ww w . j a v a 2 s .com 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 = Main.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); // 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 Jetty embedded web server."); try { 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) { System.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:hermes.browser.HermesBrowser.java
private void initJIDE() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {//from w w w . j a v a 2 s . co m try { LookAndFeelFactory.installJideExtension(); } catch (IllegalArgumentException e) { log.error("l&f incompatible with JIDE, trying metal: " + e.getMessage(), e); UIManager.setLookAndFeel(new MetalLookAndFeel()); LookAndFeelFactory.installJideExtension(); } ObjectConverterManager.initDefaultConverter(); CellEditorManager.initDefaultEditor(); CellRendererManager.initDefaultRenderer(); ObjectComparatorManager.initDefaultComparator(); LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() { public void customize(UIDefaults defaults) { Map painter = (Map) defaults.get("Theme.painter"); // ThemePainter painter = (ThemePainter) // defaults.get("Theme.painter"); defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI"); defaults.put("OptionPane.showBanner", Boolean.FALSE); // show // banner // or // not. // default // is // true defaults.put("OptionPane.bannerBackgroundDk", painter.get("OptionPane.bannerBackgroundDk")); defaults.put("OptionPane.bannerBackgroundLt", painter.get("OptionPane.bannerBackgroundLt")); defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default // is // true // optionally, you can set a Paint object for BannerPanel. If // so, the three UIDefaults related to banner background above // will be ignored. defaults.put("OptionPane.bannerBackgroundPaint", null); defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6)); defaults.put("OptionPane.buttonOrientation", new Integer(SwingConstants.RIGHT)); } }; uiDefaultsCustomizer.customize(UIManager.getDefaults()); }
From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java
public static void main(String[] args) throws Exception { Thread t = new Thread() { public void run() { try { Magic.initialize();//from ww w . j a v a 2s .c o m } catch (Exception ex) { ex.printStackTrace(); } } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); HttpClient httpClient = new HttpClient(); BdbClient.init(); JFrame frame = new JFrame(); ProxyFactory proxyFactory = VeracityProxyFactory.create(); BdbAdminClient client = new BdbAdminClient(httpClient, frame, new File("config.xml"), proxyFactory); frame.setTitle("Bdb Network Explorer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(client); frame.setSize(1024, 768); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:edu.ku.brc.specify.BackupAndRestoreApp.java
/** * /*w ww. j a v a2s. c o m*/ */ public static void startApp() { // Then set this IconManager.setApplicationClass(BackupAndRestoreApp.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); } } catch (Exception e) { UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BackupAndRestoreApp.class, e); log.error("Can't change L&F: ", e); //$NON-NLS-1$ } ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ // Startup Specify BackupAndRestoreApp backupAndRestoreApp = new BackupAndRestoreApp(); RolloverCommand.setHoverImg(IconManager.getIcon("DropIndicator")); //$NON-NLS-1$ // THis type of start up ALWAYS assumes the .Specify directory is in there "home" directory. backupAndRestoreApp.preStartUp(); backupAndRestoreApp.startUp(); }
From source file:com.sshtools.appframework.ui.SshToolsApplication.java
public void setLookAndFeel(UIManager.LookAndFeelInfo laf) { if (laf != null) { log.info("Setting Look and Feel to " + laf.getClassName()); try {/*from w w w . jav a 2s . c o m*/ @SuppressWarnings("unchecked") LookAndFeel l = createLookAndFeel((Class<LookAndFeel>) Class.forName(laf.getClassName())); UIManager.setLookAndFeel(l); Icon checkIcon = UIManager.getIcon("CheckBoxMenuItem.checkIcon"); Icon radioIcon = UIManager.getIcon("RadioButtonMenuItem.checkIcon"); UIManager.put("MenuItem.checkIcon", new EmptyIcon( Math.max(checkIcon.getIconWidth(), radioIcon.getIconWidth()), checkIcon.getIconHeight())); UIManager.put("Menu.checkIcon", new EmptyIcon( Math.max(checkIcon.getIconWidth(), radioIcon.getIconWidth()), checkIcon.getIconHeight())); for (SshToolsApplicationContainer container : containers) { container.updateUI(); } for (OptionsTab tab : additionalOptionsTabs) { SwingUtilities.updateComponentTreeUI(tab.getTabComponent()); } } catch (Throwable t) { /* DEBUG */t.printStackTrace(); } } }
From source file:dk.dma.epd.ship.EPDShip.java
private void initLookAndFeel() { try {//from w ww. j a v a2s. com // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); Properties props = new Properties(); props.put("logoString", "EPD-Ship"); props.put("backgroundPattern", "false"); props.put("textAntiAliasingMode", "TEXT_ANTIALIAS_VBGR"); // props.put("menuOpaque", "true"); // props.put("tooltipCastShadow", "true"); // small font // props.setProperty("controlTextFont", "Dialog 12"); // props.setProperty("systemTextFont", "Dialog 12"); // props.setProperty("userTextFont", "Dialog 12"); // props.setProperty("menuTextFont", "Dialog 12"); // props.setProperty("windowTitleFont", "Dialog bold 12"); // props.setProperty("subTextFont", "Dialog 10"); props.setProperty("controlTextFont", "Dialog 10"); props.setProperty("systemTextFont", "Dialog 10"); props.setProperty("userTextFont", "Dialog 10"); props.setProperty("menuTextFont", "Dialog 10"); props.setProperty("windowTitleFont", "Dialog bold 10"); props.setProperty("subTextFont", "Dialog 8"); // props.put("tooltipBorderSize", "15"); // props.put("tooltipShadowSize", "15"); // NoireLookAndFeel laf = new NoireLookAndFeel(); HiFiLookAndFeel laf = new HiFiLookAndFeel(); // NoireLookAndFeel.setCurrentTheme(props); HiFiLookAndFeel.setCurrentTheme(props); UIManager.setLookAndFeel(laf); } catch (Exception e) { LOG.error("Failed to set look and feed: " + e.getMessage()); } }
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
/** * @param args/*ww w.java2 s.c om*/ */ 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$ UIRegistry.setEmbeddedDBPath(UIRegistry.getDefaultEmbeddedDBPath()); // on the local machine for (String s : args) { String[] pairs = s.split("="); //$NON-NLS-1$ if (pairs.length == 2) { if (pairs[0].startsWith("-D")) //$NON-NLS-1$ { //System.err.println("["+pairs[0].substring(2, pairs[0].length())+"]["+pairs[1]+"]"); System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]); } } else { String symbol = pairs[0].substring(2, pairs[0].length()); //System.err.println("["+symbol+"]"); System.setProperty(symbol, symbol); } } // Now check the System Properties String appDir = System.getProperty("appdir"); if (StringUtils.isNotEmpty(appDir)) { UIRegistry.setDefaultWorkingPath(appDir); } String appdatadir = System.getProperty("appdatadir"); if (StringUtils.isNotEmpty(appdatadir)) { UIRegistry.setBaseAppDataDir(appdatadir); } Logger logger = LogManager.getLogger("edu.ku.brc"); if (logger != null) { logger.setLevel(Level.ALL); System.out.println("Setting " + logger.getName() + " to " + logger.getLevel()); } logger = LogManager.getLogger(edu.ku.brc.dbsupport.HibernateUtil.class); if (logger != null) { logger.setLevel(Level.INFO); System.out.println("Setting " + logger.getName() + " to " + logger.getLevel()); } // 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()); } final Sp5Forms frame = new Sp5Forms(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(0, 0, 800, 800); new MacOSAppHandler(frame); frame.startup(); frame.createUI(); JMenuBar mb = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMI = new JMenuItem("Open XML File"); fileMenu.add(openMI); openMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.openXML(); } }); JMenuItem openDBMI = new JMenuItem("Open Database"); fileMenu.add(openDBMI); openDBMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.openDB(); } }); JMenuItem saveMI = new JMenuItem("Save"); fileMenu.add(saveMI); saveMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.saveXML(); } }); if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); JMenuItem mi = new JMenuItem("Exit"); fileMenu.add(mi); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); } mb.add(fileMenu); frame.setJMenuBar(mb); centerAndShow(frame); } catch (Exception e) { log.error("Can't change L&F: ", e); } } }); }
From source file:hermes.browser.HermesBrowser.java
/** * Initialisation of GUI components, must be run on the Swing dispatch * thread./*from w w w. j a v a 2 s . co m*/ * * @throws ClassNotFoundException * @throws InstantiationException * @throws IllegalAccessException * @throws UnsupportedLookAndFeelException * @throws HermesException */ private void initUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, HermesException { if (System.getProperty("swing.defaultlaf") == null) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); /** * http://hermesjms.com/jira/browse/HJMS-16 I've not implemented * this fully as the L&F class name is not all we need to * persist, JIDE seems to add in lots of extension stuff and I * don't see how to persist/restor them yet. if * (TextUtils.isEmpty(getConfig().getLookAndFeel())) { * UIManager. * setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } * else { UIManager.setLookAndFeel(getConfig().getLookAndFeel()) * ; } */ } catch (Throwable e) { log.error("cannot load l&f, trying metal: " + e.getMessage(), e); UIManager.setLookAndFeel(new MetalLookAndFeel()); } } else { UIManager.setLookAndFeel(System.getProperty("swing.defaultlaf")); } if (getConfig().isEnableJython() && jythonFrame == null) { jythonFrame = new JythonDockableFrame(); getDockingManager().addFrame(jythonFrame); } if (!getConfig().isEnableJython() && jythonFrame != null) { getDockingManager().removeFrame(jythonFrame.getKey()); jythonFrame = null; } CellEditorManager.registerEditor(Domain.class, new DomainCellEditor()); CellEditorManager.registerEditor(SelectorImpl.class, new SelectorImplCellEditor()); CellEditorManager.registerEditor(File.class, new DirectoryCellEditor(), DirectoryCellEditor.CONTEXT); CellEditorManager.registerEditor(String.class, new ClasspathIdCellEdtitor(), ClasspathIdCellEdtitor.CONTEXT); CellEditorManager.registerEditor(Hermes.class, new HermesCellEditor()); ObjectComparatorManager.registerComparator(Date.class, new DateComparator()); ObjectComparatorManager.registerComparator(Integer.class, new IntegerComparator()); ObjectComparatorManager.registerComparator(Long.class, new LongComparator()); DefaultSyntaxKit.initKit(); browserPane = new MainDocumentPane(); // Shows us the memory usage and lets the user GC MemoryStatusBarItem memoryStatusBar = new MemoryStatusBarItem(); memoryStatusBar.setPreferredWidth(100); // General informative messages go here.. progressStatus = new ProgressStatusBarItem(); statusBar = new StatusBar(); statusBar.add(progressStatus, JideBoxLayout.VARY); statusBar.add(new TimeStatusBarItem(), JideBoxLayout.FLEXIBLE); statusBar.add(memoryStatusBar, JideBoxLayout.FLEXIBLE); // The tools panel includes the running tasks, Jython console and log // console. actionsPane = new ActionsPanel(); toolsPane = new DockableToolPanel(); toolsPane.addToolPanel("Tasks", new JideScrollPane(actionsPane)); toolsPane.addToolPanel("Log", new Log4JOutputViewer("")); browserTreePane = new BrowserTreeDockableFrame(); browserTreePane.setLoader(loader); // Get the menu bar initialised... setJMenuBar(new MenuBar(this)); setIconImage(IconCache.getIcon("hermes.icon").getImage()); // // Layout management initialisation getDockingManager().setUsePref(false); getDockingManager().setProfileKey(USER_PROFILE_NAME); getDockingManager().setInitSplitPriority(DefaultDockingManager.SPLIT_SOUTH_NORTH_EAST_WEST); getDockingManager().getWorkspace().add(browserPane, BorderLayout.CENTER); getDockingManager().addFrame(browserTreePane); getDockingManager().addFrame(toolsPane); getDockableBarManager().addDockableBar(new MainToolBar()); getDockableBarManager().addDockableBar(new MessageToolBar()); getDockableBarManager().addDockableBar(new ConfigurationToolBar()); getDockableBarManager().addDockableBar(new JNDIToolBar()); getContentPane().add(statusBar, BorderLayout.AFTER_LAST_LINE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); toFront(); setStatusMessage("Ready"); SplashScreen.hide(); // // Raise the swing thread to max priority SwingUtilities.invokeLater(new Runnable() { public void run() { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); } }); }
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 {//w w w. j a v a 2 s . c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { throw new RuntimeException(e); } TrayIcon trayIcon = null; if (SystemTray.isSupported()) { tellUser("Adding ePADD to the system tray"); SystemTray tray = SystemTray.getSystemTray(); URL u = ePADD.class.getClassLoader().getResource("muse-icon.png"); // note: this better be 16x16, Windows doesn't resize! Mac os does. out.println("ePADD icon resource is " + u); Image image = Toolkit.getDefaultToolkit().getImage(u); out.println("Image = " + image); // create menu items and their listeners ActionListener openMuseControlsListener = new ActionListener() { public void actionPerformed(ActionEvent e) { try { launchBrowser(BASE_URL); // 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:com.pironet.tda.TDA.java
/** * tries the native look and feel on mac and windows and metal on unix (gtk still * isn't looking that nice, even in 1.6) *//*from w ww. java 2 s. c o m*/ private void setupLookAndFeel() { try { String plaf = "Mac,Windows,Metal"; if (System.getProperty("os.name").startsWith("Linux")) { plaf = "GTK,Mac,Windows,Metal"; } // this line needs to be implemented in order to make L&F work properly UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader()); // query list of L&Fs UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); if (!Strings.isNullOrEmpty(plaf)) { String[] instPlafs = plaf.split(","); UIManager.LookAndFeelInfo currentLAFI = null; search: for (final String instPlaf : instPlafs) { for (final UIManager.LookAndFeelInfo plaf1 : plafs) { currentLAFI = plaf1; if (currentLAFI.getName().startsWith(instPlaf)) { UIManager.setLookAndFeel(currentLAFI.getClassName()); // setup SANS_SERIF setUIFont(new FontUIResource("SansSerif", Font.PLAIN, Const.FONT_SIZE)); break search; } } } } if (plaf.startsWith("GTK")) { setFontSizeModifier(2); } } catch (Exception except) { setUIFont(new FontUIResource("SansSerif", Font.PLAIN, 12)); } }