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:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private void initgui() { setName("SdkFidoFrame"); this.winhandler = new WindowHandler(this, true); this.winhandler.setPersistLocation(true); this.winhandler.setPersistSize(true); this.actionMapper = new ActionMapper(this); String lnf = Prefs.getString("looknfeel", UIManager.getCrossPlatformLookAndFeelClassName()); setLookAndFeel(lnf);/*w w w. j av a 2 s. c o m*/ setTitle("SDKFido - " + Build.getVersion()); getContentPane().setLayout(new BorderLayout()); enableExitKey(); // Menu Bar setJMenuBar(createMainMenu()); Container content = getContentPane(); content.add(BorderLayout.CENTER, createBody()); pack(); Dimension minDim = getPreferredSize(); setMinimumSize(minDim); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.winhandler.setSizePreferred(new Dimension(400, 400)); addWindowListener(this.winhandler); }
From source file:LookAndFeelDemo.java
private static void initLookAndFeel() { String lookAndFeel = null;/* w w w .j a v a 2s. co m*/ 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:com.nubits.nubot.launch.toolkit.LaunchUI.java
private String askUser() { //Create Options for option dialog String path = ""; // Set cross-platform Java L&F (also called "Metal") try {/*from w ww . j ava 2 s . c o m*/ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); final ImageIcon icon = new ImageIcon(local_path + "/" + ICON_PATH); //Ask the user to ask for scratch Object[] options = { "Import existing JSON option file", "Configure the bot from scratch" }; int n = JOptionPane.showOptionDialog(new JFrame(), "Chose one of the following options:", "NuBot UI Launcher", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon, //do not use a custom Icon options, //the titles of buttons options[0]); //default button title if (n == JOptionPane.YES_OPTION) { //Prompt user to chose a file. JFileChooser fileChooser = createFileChoser(); int result = fileChooser.showOpenDialog(new JFrame()); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); path = selectedFile.getAbsolutePath(); LOG.info("Option file selected : " + path); } else { LOG.info("Closing Launch UI utility."); System.exit(0); } } } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException e) { LOG.error(e.toString()); } return path; }
From source file:components.Converter.java
private static void initLookAndFeel() { String lookAndFeel = null;/* w ww . ja va 2s.c om*/ 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+")) { //new in 1.4.2 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); } 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:de.tbuchloh.kiskis.util.Settings.java
/** * @return the currently used L&F./*from w w w . j a v a2 s. c om*/ */ public static String getDefaultLookAndFeel() { final String os = System.getProperty("os.name"); String def = null; if (os.indexOf("Mac") != -1) { def = UIManager.getCrossPlatformLookAndFeelClassName(); } else { def = D_DEFAULT_LNF; } return PREF.get(K_DEFAULT_LNF, def); }
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);//from w w w. j a v a 2 s .co 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:com.alvermont.terraj.util.ui.LookAndFeelUtils.java
/** * Change the look and feel to either the native one or the cross * platform Java one//from w w w . j a va 2 s.co m * * @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:org.pentaho.aggdes.ui.UIMain.java
private void setLAF() { try {// www .j av a 2 s .c o m 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:Converter.java
private static void initLookAndFeel() { String lookAndFeel = null;//from ww w . j av a 2 s.c om 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+")) { // new in 1.4.2 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); } 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:com.googlecode.logVisualizer.LogVisualizer.java
private LogVisualizer() { try {//from ww w .j av a 2 s . c om final String wantedLaf = Settings.getSettingString("LookAndFeel"); LookAndFeelInfo usedLaf = null; for (final LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels()) if (lafi.getName().equals(wantedLaf)) { usedLaf = lafi; break; } if (usedLaf != null) UIManager.setLookAndFeel(usedLaf.getClassName()); else UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (final Exception e) { e.printStackTrace(); } gui = new LogVisualizerGUI(new LogLoaderListener() { public void loadMafiaLog(final File file) { loadLog(file, new MafiaLogParser(file, Settings.getSettingBoolean("Include mafia log notes"))); } public void loadPreparsedLog(final File file) { loadLog(file, new PreparsedLogParser(file)); } public void loadXMLLog(final File file) { try { final LogDataHolder logData = XMLLogReader.parseXMLLog(file); addLogGUI(file, logData); } catch (final FileAccessException e) { e.printStackTrace(); JOptionPane.showMessageDialog(gui, "A problem occurred while reading the file.", "Error occurred", JOptionPane.ERROR_MESSAGE); } catch (final XMLAccessException e) { e.printStackTrace(); JOptionPane.showMessageDialog(gui, "A problem occurred while parsing the XML.", "Error occurred", JOptionPane.ERROR_MESSAGE); } } }); gui.setSize(800, 600); RefineryUtilities.centerFrameOnScreen(gui); gui.setVisible(true); if (Settings.getSettingBoolean("First program startup")) { final JLabel text = new JLabel( "<html>Note that <b>for the purpose of logging your own runs with KolMafia, it is best</b> to " + "turn on all options but <i>Log adventures left instead of adventures used</i> under " + "<i>General->Preferences->Session Logs</i> in KolMafia." + "<br><br><br>This informational popup will only be displayed this once.</html>"); text.setPreferredSize(new Dimension(550, 100)); JOptionPane.showMessageDialog(gui, text, "KolMafia logging options", JOptionPane.INFORMATION_MESSAGE); Settings.setSettingBoolean("First program startup", false); } if (Settings.getSettingBoolean("Check Updates")) new Thread(new Runnable() { public void run() { if (ProjectUpdateViewer.isNewerVersionUploaded()) EventQueue.invokeLater(new Runnable() { public void run() { UpdateDialog.showDialog(gui); } }); } }).start(); }