List of usage examples for javax.swing UIManager getInstalledLookAndFeels
public static LookAndFeelInfo[] getInstalledLookAndFeels()
From source file:CascadeDemo.java
public CascadeDemo() { super("CascadeDemo"); EARTH = new ImageIcon("earth.jpg"); m_count = m_tencount = 0;/*from www.jav a 2 s. c om*/ m_desktop = new JDesktopPane(); m_desktop.putClientProperty("JDesktopPane.dragMode", "outline"); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); setSize(570, 400); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); }
From source file:captor.app.CaptorGui.java
protected static void installLookAndFeel(Model model) { boolean useConfiguredLNF = false; UIManager.LookAndFeelInfo[] installed = UIManager.getInstalledLookAndFeels(); try {/* w w w .j ava 2 s. c o m*/ for (LookAndFeelInfo lnf : installed) { String name = lnf.getClassName(); if (name.equals(model.getConfig().getGuiConfig().getLookAndFeel())) { useConfiguredLNF = true; break; } } if (useConfiguredLNF) { try { UIManager.setLookAndFeel(model.getConfig().getGuiConfig().getLookAndFeel()); } catch (Exception e) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) { System.out.println("Cannot install look and feel."); } }
From source file:cl.almejo.vsim.Main.java
private void setNimbusLookAndFeel() { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException e) { e.printStackTrace();/*from w ww.j av a 2 s.c o m*/ } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } break; } } }
From source file:Main.java
/** * Enables look and feel with specified name only if such LaF is available * * @param lafName look and feel name// w w w. j a v a 2 s . c o m */ public static void enableLafIfAvailable(String lafName) { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (lafName.equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); break; } catch (Exception e) { // ignore } } } }
From source file:LookAndFeelPrefs.java
/** * Create a menu of radio buttons listing the available Look and Feels. When * the user selects one, change the component hierarchy under frame to the new * LAF, and store the new selection as the current preference for the package * containing class c./*from w w w. ja va 2 s. c o m*/ */ public static JMenu createLookAndFeelMenu(final Class prefsClass, final ActionListener listener) { // Create the menu final 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(); // Find out which one is currently used String currentLAFName = UIManager.getLookAndFeel().getClass().getName(); // 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 final JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName)); item.setSelected(plafClassName.equals(currentLAFName)); // Tell the menu item what to do when it is selected item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // Set the new look and feel try { UIManager.setLookAndFeel(plafClassName); } catch (UnsupportedLookAndFeelException e) { // Sometimes a Look-and-Feel is installed but not // supported, as in the Windows LaF on Linux platforms. JOptionPane.showMessageDialog(plafmenu, "The selected Look-and-Feel is " + "not supported on this platform.", "Unsupported Look And Feel", JOptionPane.ERROR_MESSAGE); item.setEnabled(false); } catch (Exception e) { // ClassNotFound or Instantiation item.setEnabled(false); // shouldn't happen } // Make the selection persistent by storing it in prefs. Preferences p = Preferences.userNodeForPackage(prefsClass); p.put(PREF_NAME, plafClassName); // Invoke the supplied action listener so the calling // application can update its components to the new LAF // Reuse the event that was passed here. listener.actionPerformed(event); } }); // Only allow one menu item to be selected at once radiogroup.add(item); } return plafmenu; }
From source file:JVM.java
/** * Constructor for the OS object/* w w w . java 2 s. c o m*/ */ public JVM(String p_JavaVersion) { if (p_JavaVersion.startsWith("1.7.")) { jdkVersion = JDK1_7; } else if (p_JavaVersion.startsWith("1.6.")) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel".equals(info.getClassName())) { jdkVersion = JDK1_6N; break; } } jdkVersion = jdkVersion == 0 ? JDK1_6 : jdkVersion; } else if (p_JavaVersion.startsWith("1.5.")) { jdkVersion = JDK1_5; } else if (p_JavaVersion.startsWith("1.4.")) { jdkVersion = JDK1_4; } else if (p_JavaVersion.startsWith("1.3.")) { jdkVersion = JDK1_3; } else if (p_JavaVersion.startsWith("1.2.")) { jdkVersion = JDK1_2; } else if (p_JavaVersion.startsWith("1.1.")) { jdkVersion = JDK1_1; } else if (p_JavaVersion.startsWith("1.0.")) { jdkVersion = JDK1_0; } else { // unknown version, assume 1.3 jdkVersion = JDK1_3; } }
From source file:org.jahia.loganalyzer.internal.JahiaLogAnalyzerImpl.java
public static void initUI() { try {//from w ww . j a v a 2 s . com for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. try { UIManager.setLookAndFeel(new PlasticXPLookAndFeel()); } catch (Throwable t) { log.error("Error setting look and feel", t); } } }
From source file:InternalFrameListenerDemo.java
public InternalFrameListenerDemo() { setTitle("Animated InternalFrameListener"); m_count = m_tencount = 0;/*w w w . java2 s .com*/ JPanel innerListenerPanel = new JPanel(new GridLayout(7, 1)); JPanel listenerPanel = new JPanel(new BorderLayout()); m_ifEventCanvas = new IFEventCanvas(); m_lOpened = new JLabel("internalFrameOpened"); m_lClosing = new JLabel("internalFrameClosing"); m_lClosed = new JLabel("internalFrameClosed"); m_lIconified = new JLabel("internalFrameIconified"); m_lDeiconified = new JLabel("internalFrameDeiconified"); m_lActivated = new JLabel("internalFrameActivated"); m_lDeactivated = new JLabel("internalFrameDeactivated"); innerListenerPanel.add(m_lOpened); innerListenerPanel.add(m_lClosing); innerListenerPanel.add(m_lClosed); innerListenerPanel.add(m_lIconified); innerListenerPanel.add(m_lDeiconified); innerListenerPanel.add(m_lActivated); innerListenerPanel.add(m_lDeactivated); listenerPanel.add("Center", m_ifEventCanvas); listenerPanel.add("West", innerListenerPanel); listenerPanel.setOpaque(true); listenerPanel.setBackground(Color.white); m_desktop = new JDesktopPane(); m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.setLayout(new FlowLayout()); topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED)))); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); getContentPane().add("South", listenerPanel); ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED)))); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); setSize(645, 500); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); m_eventTimer = new Timer(1000, this); m_eventTimer.setRepeats(true); m_eventTimer.start(); }
From source file:com.josescalia.tumblr.app.MainFrame.java
/** * @param args the command line arguments */// www . ja va 2s . co m public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ EventQueue.invokeLater(new Runnable() { public void run() { new MainFrame().setVisible(true); } }); }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
private void setLookAndFeel() { System.setProperty("awt.useSystemAAFontSettings", "on"); System.setProperty("swing.aatext", "true"); WindowUtils.fixDisplayOnLinux(this); try {/*from w w w . j a va 2 s . c om*/ for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { //keep the default } }