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:com.xmage.launcher.XMageLauncher.java
public static void main(String[] args) { try {/*ww w .j a v a 2s. c om*/ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); XMageLauncher gui = new XMageLauncher(); SwingUtilities.invokeLater(gui); } catch (ClassNotFoundException ex) { logger.error("Error: ", ex); } catch (InstantiationException ex) { logger.error("Error: ", ex); } catch (IllegalAccessException ex) { logger.error("Error: ", ex); } catch (UnsupportedLookAndFeelException ex) { logger.error("Error: ", ex); } }
From source file:JDAC.JDAC.java
public static void main(String[] args) { try {/* w w w . j ava 2s . c o m*/ UIManager.setLookAndFeel( //UIManager.getSystemLookAndFeelClassName()); UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { JOptionPane.showMessageDialog(new Frame(), "" + "Something strange happened\n" + "If the error persists please contact the system administrator\n" + "ERR: theme error"); } JDAC demo = new JDAC(); RefineryUtilities.centerFrameOnScreen(demo); Runnable tmp = new Runnable() { public void run() { System.out.println("JDAC"); System.out.println("Credits: Michele Lizzit - https://lizzit.it/jdac"); searchForPorts(); } }; tmp.run(); }
From source file:llc.rockford.webcast.EC2Driver.java
private void initLookAndFeel() { String lookAndFeel = null;//from w w w .j a v a 2 s . c o m if (LOOKANDFEEL != null) { if (LOOKANDFEEL.equals("Metal")) { lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } 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()); 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:components.FrameDemo2.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./*from w w w .java 2 s . co m*/ */ private static void createAndShowGUI() { //Use the Java look and feel. try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { } //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); //Instantiate the controlling class. JFrame frame = new JFrame("FrameDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. FrameDemo2 demo = new FrameDemo2(); //Add components to it. Container contentPane = frame.getContentPane(); contentPane.add(demo.createOptionControls(), BorderLayout.CENTER); contentPane.add(demo.createButtonPane(), BorderLayout.PAGE_END); frame.getRootPane().setDefaultButton(defaultButton); //Display the window. frame.pack(); frame.setLocationRelativeTo(null); //center it frame.setVisible(true); }
From source file:gate.Main.java
/** * Reads the user config data and applies the required settings. * This must be called <b>after</b> {@link Gate#init()} but <b>before</b> * any GUI components are created.//from w ww .j a va 2 s . c om */ public static void applyUserPreferences() { //look and feel String lnfClassName; if (System.getProperty("swing.defaultlaf") != null) { lnfClassName = System.getProperty("swing.defaultlaf"); } else { lnfClassName = Gate.getUserConfig().getString(GateConstants.LOOK_AND_FEEL); } if (lnfClassName == null) { //if running on Linux, default to Metal rather than GTK because GTK LnF //doesn't play nicely with most Gnome themes if (System.getProperty("os.name").toLowerCase().indexOf("linux") != -1) { //running on Linux lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } else { lnfClassName = UIManager.getSystemLookAndFeelClassName(); } } try { UIManager.setLookAndFeel(lnfClassName); } catch (Exception e) { System.err.print("Could not set your preferred Look and Feel. The error was:\n" + e.toString() + "\nReverting to using Java Look and Feel"); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e1) { //we just can't catch a break here. Let's forget about look and feel. System.err.print("Could not set the cross-platform Look and Feel either. The error was:\n" + e1.toString() + "\nGiving up on Look and Feel."); } } Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName); //read the user config data OptionsMap userConfig = Gate.getUserConfig(); //text font Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("TextPane.font"); } if (font != null) { OptionsDialog.setTextComponentsFont(font); } //menus font font = userConfig.getFont(GateConstants.MENUS_FONT); if (font == null) { font = UIManager.getFont("Menu.font"); } if (font != null) { OptionsDialog.setMenuComponentsFont(font); } //other gui font font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("Button.font"); } if (font != null) { OptionsDialog.setComponentsFont(font); } }
From source file:FrameDemo2.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *///from w w w . j a va 2s.com private static void createAndShowGUI() { // Use the Java look and feel. try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { } // Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); // Instantiate the controlling class. JFrame frame = new JFrame("FrameDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the content pane. FrameDemo2 demo = new FrameDemo2(); // Add components to it. Container contentPane = frame.getContentPane(); contentPane.add(demo.createOptionControls(), BorderLayout.CENTER); contentPane.add(demo.createButtonPane(), BorderLayout.PAGE_END); frame.getRootPane().setDefaultButton(defaultButton); // Display the window. frame.pack(); frame.setLocationRelativeTo(null); // center it frame.setVisible(true); }
From source file:net.sf.jabref.JabRefGUI.java
private void setLookAndFeel() { try {/* w ww . j av a2 s.co m*/ String lookFeel; String systemLookFeel = UIManager.getSystemLookAndFeelClassName(); if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) { // FIXME: Problems with OpenJDK and GTK L&F // See https://github.com/JabRef/jabref/issues/393, https://github.com/JabRef/jabref/issues/638 if (System.getProperty("java.runtime.name").contains("OpenJDK")) { // Metal L&F lookFeel = UIManager.getCrossPlatformLookAndFeelClassName(); LOGGER.warn( "There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution."); } else { lookFeel = systemLookFeel; } } else { lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); } // FIXME: Open JDK problem if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel) && !System.getProperty("java.runtime.name").contains("OpenJDK")) { // try to avoid ending up with the ugly Metal L&F Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel(); Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer()); com.jgoodies.looks.Options.setPopupDropShadowEnabled(true); UIManager.setLookAndFeel(lnf); } else { try { UIManager.setLookAndFeel(lookFeel); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { // specified look and feel does not exist on the classpath, so use system l&f UIManager.setLookAndFeel(systemLookFeel); // also set system l&f as default Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLookFeel); // notify the user JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(), Localization.lang( "Unable to find the requested look and feel and thus the default one is used."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE); LOGGER.warn("Unable to find requested look and feel", e); } } } catch (Exception e) { LOGGER.warn("Look and feel could not be set", e); } // In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms boolean overrideDefaultFonts = Globals.prefs.getBoolean(JabRefPreferences.OVERRIDE_DEFAULT_FONTS); if (overrideDefaultFonts) { int fontSize = Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE); UIDefaults defaults = UIManager.getDefaults(); Enumeration<Object> keys = defaults.keys(); for (Object key : Collections.list(keys)) { if ((key instanceof String) && ((String) key).endsWith(".font")) { FontUIResource font = (FontUIResource) UIManager.get(key); font = new FontUIResource(font.getName(), font.getStyle(), fontSize); defaults.put(key, font); } } } }
From source file:com.sshtools.common.ui.SshToolsApplication.java
/** * * * @param className/*from ww w.ja v a 2s. com*/ * * @throws Exception */ public static void setLookAndFeel(String className) throws Exception { LookAndFeel laf = null; if (!className.equals(DEFAULT_LAF)) { if (className.equals(SYSTEM_LAF)) { String systemLaf = UIManager.getSystemLookAndFeelClassName(); log.debug("System Look And Feel is " + systemLaf); laf = (LookAndFeel) Class.forName(systemLaf).newInstance(); } else if (className.equals(CROSS_PLATFORM_LAF)) { String crossPlatformLaf = UIManager.getCrossPlatformLookAndFeelClassName(); log.debug("Cross Platform Look And Feel is " + crossPlatformLaf); laf = (LookAndFeel) Class.forName(crossPlatformLaf).newInstance(); } else { laf = (LookAndFeel) Class.forName(className).newInstance(); } } // Now actually set the look and feel if (laf != null) { log.info("Setting look and feel " + laf.getName() + " (" + laf.getClass().getName() + ")"); UIManager.setLookAndFeel(laf); UIManager.put("EditorPane.font", UIManager.getFont("TextArea.font")); } }
From source file:org.pegadi.client.ApplicationLauncher.java
protected void setTheme(String theme) { //TODO: fix nullpointerexception log.debug("theme: {}", theme); String lfTheme;/*from w w w . j av a 2 s. co m*/ if (theme.equalsIgnoreCase("system")) { lfTheme = UIManager.getSystemLookAndFeelClassName(); } else if (theme.equalsIgnoreCase("swing")) { lfTheme = UIManager.getCrossPlatformLookAndFeelClassName(); lfTheme = UIManager.getSystemLookAndFeelClassName(); } else if (theme.equalsIgnoreCase("gtk")) { lfTheme = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; //DEBUG lfTheme = UIManager.getSystemLookAndFeelClassName(); } else { log.error("Invalid L&F theme"); throw new IllegalArgumentException("'" + theme + "' is not a supported L&F"); } if (!lfTheme.equals(UIManager.getLookAndFeel().getName())) { try { UIManager.setLookAndFeel(lfTheme); } catch (Exception e) { log.warn("Unable to set selected L&F, swapping to a default L&F"); UIManager.LookAndFeelInfo[] installedLF = UIManager.getInstalledLookAndFeels(); try { UIManager.setLookAndFeel(installedLF[0].getClassName()); } catch (Exception e2) { log.error("Unable to load any L&F, exiting", e2); System.exit(-1); } } try { log.debug("attempting to update componenttreeui"); SwingUtilities.updateComponentTreeUI(this.getContentPane()); } catch (Exception swe) { log.error("Unable to update component tree", swe); } } pack(); //Might be the cause of occasional NullpointEx due to system //not being able to locate LookAndFeel }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
public static void main(String[] args) throws Exception { try {//from w w w . ja v a 2 s. c o m UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } Logger.getRootLogger().setLevel(Level.INFO); DataPreparationToolGUI dataPreparationToolGUI = new DataPreparationToolGUI(); if (args.length == 1 && args[0].equals("dev")) { Utilities.isDev = true; } dataPreparationToolGUI.setupTool(); dataPreparationToolGUI.setVisible(true); }