List of usage examples for javax.swing UIManager getCrossPlatformLookAndFeelClassName
public static String getCrossPlatformLookAndFeelClassName()
LookAndFeel
class that implements the default cross platform look and feel -- the Java Look and Feel (JLF). From source file:org.gcaldaemon.gui.ConfigEditor.java
public final void setLookAndFeel(String className) { try {/*from w w w . j a v a 2 s . c o m*/ UIManager.setLookAndFeel(className); config.setConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, className); } catch (Exception error) { log.warn(error); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception ignored) { } } }
From source file:org.kuali.test.creator.TestCreator.java
/** * * @param args// w w w. ja v a 2s . c o m */ public static void main(final String args[]) { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception ex) { LOG.error(ex.toString(), ex); } if (!ApplicationInstanceManager .registerInstance(ApplicationInstanceManager.SINGLE_INSTANCE_NETWORK_SOCKET1)) { // instance already running. System.out.println("Another instance of this application is already running. Exiting."); System.exit(0); } else { ApplicationInstanceManager.setApplicationInstanceListener(new ApplicationInstanceListener() { @Override public void newInstanceCreated() { } }); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { String filename = null; if (args.length > 0) { filename = args[0]; } try { if (checkConfiguration(filename)) { new TestCreator(filename).setVisible(true); } else { System.exit(-1); } } catch (Exception ex) { LOG.error(ex.toString(), ex); System.exit(-1); } } }); } }
From source file:org.openscience.jmol.app.Jmol.java
public static Jmol getJmol(JFrame frame, int startupWidth, int startupHeight, String commandOptions) { Splash splash = null;/* w ww .j a v a 2 s.c om*/ if (haveDisplay.booleanValue()) { ImageIcon splash_image = JmolResourceHandler.getIconX("splash"); report("splash_image=" + splash_image); splash = new Splash(frame, splash_image); splash.setCursor(new Cursor(Cursor.WAIT_CURSOR)); splash.showStatus(GT._("Creating main window...")); splash.showStatus(GT._("Initializing Swing...")); } try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception exc) { System.err.println("Error loading L&F: " + exc); } screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (splash != null) splash.showStatus(GT._("Initializing Jmol...")); Jmol window = new Jmol(splash, frame, null, startupWidth, startupHeight, commandOptions); if (haveDisplay.booleanValue()) frame.show(); return window; }
From source file:org.ut.biolab.medsavant.MedSavantClient.java
private static void setLAF() { try {// w w w . j a v a2 s . com if (ClientMiscUtils.MAC) { customizeForMac(); } // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); //Metal works with sliders. //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); //GTK doesn't work with sliders. //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); //Nimbus doesn't work with sliders. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { LOG.debug("Installed LAF: " + info.getName() + " class: " + info.getClassName()); } LOG.debug("System LAF is: " + UIManager.getSystemLookAndFeelClassName()); LOG.debug("Cross platform LAF is: " + UIManager.getCrossPlatformLookAndFeelClassName()); LookAndFeelFactory.addUIDefaultsInitializer(new LookAndFeelFactory.UIDefaultsInitializer() { public void initialize(UIDefaults defaults) { Map<String, Object> defaultValues = new HashMap<String, Object>(); defaultValues.put("Slider.trackWidth", new Integer(7)); defaultValues.put("Slider.majorTickLength", new Integer(6)); defaultValues.put("Slider.highlight", new ColorUIResource(255, 255, 255)); defaultValues.put("Slider.horizontalThumbIcon", javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon()); defaultValues.put("Slider.verticalThumbIcon", javax.swing.plaf.metal.MetalIconFactory.getVerticalSliderThumbIcon()); defaultValues.put("Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0)); for (Map.Entry<String, Object> e : defaultValues.entrySet()) { if (defaults.get(e.getKey()) == null) { LOG.debug("Missing key " + e.getKey() + ", using default value " + e.getValue()); defaults.put(e.getKey(), e.getValue()); } else { LOG.debug("Found key " + e.getKey() + " with value " + defaults.get(e.getKey())); } } } }); if (MiscUtils.WINDOWS) { UIManager.put("CheckBox.background", new javax.swing.plaf.ColorUIResource(Color.WHITE)); UIManager.put("Panel.background", new javax.swing.plaf.ColorUIResource(Color.WHITE)); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE_WITHOUT_MENU); /*UIManager.put("JideTabbedPane.tabAreaBackground", new javax.swing.plaf.ColorUIResource(Color.WHITE)); UIManager.put("JideTabbedPane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE)); UIManager.put("SidePane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));*/ } else { LookAndFeelFactory.installJideExtension(); } LookAndFeelFactory.installDefaultLookAndFeelAndExtension(); System.setProperty("awt.useSystemAAFontSettings", "on"); System.setProperty("swing.aatext", "true"); UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0)); //tooltips UIManager.put("ToolTip.background", new ColorUIResource(255, 255, 255)); ToolTipManager.sharedInstance().setDismissDelay(8000); ToolTipManager.sharedInstance().setInitialDelay(500); } catch (Exception x) { LOG.error("Unable to install look & feel.", x); } }
From source file:phex.gui.common.LookAndFeelUtils.java
/** * Determines the LAF to use for Phex. The LAF is supported and available. * It takes three steps:// w ww . ja v a2 s .c o m * First the given defaultClass is tried. * Second the Phex default LAF is tried. * Third the Java default is used. * @param defaultClass the default class to try. * @return the LAF class to use. */ public static LookAndFeel determineLAF(String defaultClass) { String lafClass = defaultClass; // first.. try the requested LAF LookAndFeel laf = (LookAndFeel) ClassUtils.newInstanceQuitly(ClassUtils.classForNameQuitly(lafClass)); if (laf != null && laf.isSupportedLookAndFeel()) { return laf; } // second.. try the Phex default LAF lafClass = getDefaultLAFClassName(); laf = (LookAndFeel) ClassUtils.newInstanceQuitly(ClassUtils.classForNameQuitly(lafClass)); if (laf != null && laf.isSupportedLookAndFeel()) { return laf; } // third.. try the Swing default LAF lafClass = UIManager.getCrossPlatformLookAndFeelClassName(); laf = (LookAndFeel) ClassUtils.newInstanceQuitly(ClassUtils.classForNameQuitly(lafClass)); return laf; }
From source file:prometheus.Prometheus.java
/** * Set look and feel for any UI screens used by this application. *//*from w ww . j a v a 2 s .c om*/ protected void setLookAndFeel() { try { // Use Java Platform Look & Feel UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { System.err.println(e.getMessage()); } }
From source file:qic.Main.java
public static void reloadLookAndFeel() { if (Config.getBooleanProperty(Config.LOOK_AND_FEEL_DECORATED, false)) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); System.setProperty("sun.awt.noerasebackground", "true"); }/*from ww w . j a v a 2s .c o m*/ try { String lookAndFeel = Config.getPropety(Config.LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); if (lookAndFeel.startsWith("Substance")) { lookAndFeel = "org.pushingpixels.substance.api.skin." + lookAndFeel; } UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception ex) { throw new RuntimeException(ex); } } for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } }
From source file:storybook.toolkit.swing.SwingUtil.java
public static void setLookAndFeel(LookAndFeel lookAndFeel) { try {// ww w. j a va 2 s . c o m String lafClassName = UIManager.getCrossPlatformLookAndFeelClassName(); switch (lookAndFeel) { case cross: lafClassName = UIManager.getCrossPlatformLookAndFeelClassName(); break; // case system: // lafClassName = UIManager.getSystemLookAndFeelClassName(); // break; default: lafClassName = UIManager.getCrossPlatformLookAndFeelClassName(); break; } PrefUtil.set(PreferenceKey.LAF, lookAndFeel.name()); UIManager.setLookAndFeel(lafClassName); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { } }
From source file:us.derfers.tribex.rapids.Loader.java
/** * Starts loading the GUI. Sets Swing look and feel, then loads the GUI using the GUI_Swing object. * @param escapedFile The content .rsm file to load UI elements from. * @param parent The (optional) parent Object, Eg, a JFrame or JPanel. * @param engine The JavaScript engine to pass to GUI_Swing *///from w ww . j a v a 2 s .co m public void loadAll(String escapedFile) { //Attempt to load .rsm file filePath try { //Parse filePath Document doc = Utilities.XMLStringToDocument(escapedFile); //Stabilize parsed document doc.normalize(); //Get body element NodeList mainNodeList = doc.getElementsByTagName("rsm"); //Make sure there is only ONE body element if (mainNodeList.getLength() == 1) { debugMsg("Parsing Main Element", 4); //Get rsm Element Element mainElement = (Element) mainNodeList.item(0); debugMsg("Setting Theme", 4); //If the mainElement has the attribute "theme" if (mainElement.getAttributeNode("theme") != null) { //Get the value of the attribute theme for the body element Attr swing_Theme = mainElement.getAttributeNode("theme"); //See if the rsm file specifies a theme other than camo if (swing_Theme != null && !swing_Theme.getNodeValue().equalsIgnoreCase("camo")) { try { //Split the theme into the jarfile and the classname (JARFILE.jar : com.stuff.stuff.theme) String[] splitTheme = swing_Theme.getNodeValue().split(":"); System.out.println(splitTheme[0].trim() + "**" + splitTheme[1].trim()); //Attempt to dynamically load the specified jarfile Sys.addJarToClasspath(Globals.getCWD(splitTheme[0].trim())); //Attempt to set the look'n'feel to the theme specified by the file UIManager.setLookAndFeel(splitTheme[1].trim()); debugMsg("Look and Feel set to '" + swing_Theme.getNodeValue() + "'.", 3); } catch (Exception e) { //If unable to set to .rsm's theme, use the system look'n'feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception a) { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } Utilities.showError( "Error loading Look and Feel Specified, Look and Feel set to System"); e.printStackTrace(); } } else { //If swing_Theme == camo or is not set, use the system look'n'feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception a) { a.printStackTrace(); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } debugMsg("Look and Feel (Swing) set to System", 3); } } else { //If swing_Theme == camo or is not set, use the system look'n'feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception a) { a.printStackTrace(); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } debugMsg("Look and Feel (Swing) set to System", 3); } //Parse styles for (int i = 0; i < mainElement.getElementsByTagName("style").getLength(); i++) { Element styleElement = (Element) mainElement.getElementsByTagName("style").item(i); //Load all styles from the style tags if (styleElement.getAttributeNode("href") != null) { loadStyles(null, styleElement.getTextContent()); } else { loadStyles(styleElement.getTextContent(), null); } } //Parse links for (int i = 0; i < mainElement.getElementsByTagName("link").getLength(); i++) { Element linkElement = (Element) mainElement.getElementsByTagName("link").item(i); parseLinks(linkElement, engine); } //Parse JavaScript in <script> tags Main.loader.loadJS(escapedFile, engine); //Parse GUI for (int i = 0; i < mainElement.getElementsByTagName("window").getLength(); i++) { GUI.loadWindow((Element) mainElement.getElementsByTagName("window").item(i), engine); } } else { //There was more than one body tag, or 0 body tags //Display Error and quit, as we cannot recover from an abnormally formatted file Utilities.showError("Error: More or less than one <rsm> tag in '" + escapedFile + "'.\n\n" + "Please add ONE <rsm> tag to '" + escapedFile + "'."); System.exit(1); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } }