List of usage examples for javax.swing UIManager getInstalledLookAndFeels
public static LookAndFeelInfo[] getInstalledLookAndFeels()
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { Color SELECTED_COLOR = new Color(184, 204, 217); Color BASE_COLOR = new Color(220, 231, 243, 50); Color ALT_COLOR = new Color(220, 231, 243, 115); // Insets MENU_INSETS = new Insets(1,12,2,5);//default values // Font MENU_FONT = new Font("SansSerif ", Font.PLAIN, 12);//default values // UIManager.put("nimbusBase", BASE_COLOR); UIManager.put("nimbusSelection", SELECTED_COLOR); UIManager.put("nimbusSelectionBackground", SELECTED_COLOR); UIManager.put("Menu[Enabled+Selected].backgroundPainter", SELECTED_COLOR); //override defaults for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals("Nimbus")) { UIManager.setLookAndFeel(info.getClassName()); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); defaults.put("Table.gridColor", Color.lightGray); defaults.put("Table.disabled", false); defaults.put("Table.showGrid", true); defaults.put("Table.intercellSpacing", new Dimension(1, 1)); break; }/*from w w w .j a v a2 s . c o m*/ } // UIManager.put("TitledBorder.position", TitledBorder.TOP); // UIManager.put("Table.showGrid", true); // UIManager.put("Table.gridColor", Color.RED); // UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (UnsupportedLookAndFeelException ulafe) { // logger.fatal("Substance failed to set", ulafe); } catch (Exception ex) { // logger.fatal(ex.getMessage(), ex); } JFrame frame = new Jmetrik(); // set window to maximum size but account for taskbar GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = env.getMaximumWindowBounds(); int width = Double.valueOf(rect.getWidth() - 1.0).intValue(); int height = Double.valueOf(rect.getHeight() - 1.0).intValue(); frame.setMaximizedBounds(new Rectangle(0, 0, width, height)); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); frame.pack(); // frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); //check for updates to jmetrik ((Jmetrik) frame).checkForUpdates(); } }); }
From source file:forms.frDados.java
/** * Aplica um tema s janelas da aplicao.//w ww .ja v a2 s . c o m * @param e Evento do menu de temas. */ @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JMenuItem) { String name = ((JMenuItem) e.getSource()).getText(); try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals(name)) UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(jfcArquivo); SwingUtilities.updateComponentTreeUI(frCadastro); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(frDados.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:nl.tudelft.goal.SimpleIDE.SimpleIDE.java
/** * Sets look and feel. Gets preference settings from * {@link GUIandFilePreferencePanel}./*from w ww . ja v a 2 s . c o m*/ */ private void setLookAndFeel() { if (IDEPreferences.getLAF().equals("Nimbus")) { //$NON-NLS-1$ try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { //$NON-NLS-1$ UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { new Warning(Resources.get(WarningStrings.FAILED_LAF_NIMBUS), e); } } UIManager.put("TextArea.font", UIManager.getFont("TextArea.font") //$NON-NLS-1$ //$NON-NLS-2$ .deriveFont((float) IDEPreferences.getConsoleFontSize())); }
From source file:nz.co.fortytwo.freeboard.installer.InstalManager.java
public static void main(String[] args) { System.out.println("Current dir:" + new File(".").getAbsolutePath()); try {/*from w ww . j a v a 2 s .co m*/ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (UnsupportedLookAndFeelException e) { // handle exception } catch (ClassNotFoundException e) { // handle exception } catch (InstantiationException e) { // handle exception } catch (IllegalAccessException e) { // handle exception } EventQueue.invokeLater(new Runnable() { public void run() { new InstalManager("FreeBoard - Install Manager").setVisible(true); } }); }
From source file:org.apache.jackrabbit.oak.explorer.Explorer.java
private static void initLF() { try {/* ww w. ja va2 s. c o m*/ for (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. } }
From source file:org.eclipse.wb.internal.swing.laf.LafSupport.java
/** * Enumerates all available {@link LafInfo} and stores it into <code>m_lafList</code>. *//* w ww. j a v a2s. c o m*/ private static void createLAFList() { if (m_lafList == null) { m_lafList = Lists.newArrayList(); CategoryInfo rootCategory = new CategoryInfo(ROOT_ID, "<root>"); m_lafList.add(rootCategory); // add "undefined" and "current system" rootCategory.add(SystemLafInfo.INSTANCE); rootCategory.add(UndefinedLafInfo.INSTANCE); rootCategory.add(new SeparatorLafInfo()); // enumerate system LAFs CategoryInfo jdkCategory = new CategoryInfo("JRE", "JRE"); m_lafList.add(jdkCategory); LookAndFeelInfo[] systemLAFs = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < systemLAFs.length; i++) { LookAndFeelInfo laf = systemLAFs[i]; jdkCategory.add(new LafInfo(laf.getName(), laf.getName(), laf.getClassName())); } // add LAFs using plugin API List<IConfigurationElement> categoryElements = ExternalFactoriesHelper.getElements(EXTERNAL_LAF_POINT, "category"); for (IConfigurationElement categoryElement : categoryElements) { CategoryInfo category; if (ROOT_ID.equals(ExternalFactoriesHelper.getRequiredAttribute(categoryElement, "id"))) { category = rootCategory; } else { category = new CategoryInfo(categoryElement); m_lafList.add(category); } for (IConfigurationElement lafElement : categoryElement.getChildren("LookAndFeel")) { if (isConditionTrue(lafElement)) { category.add(new PluginLafInfo(lafElement)); } } } // apply commands commands_apply(); } }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Sets the L&F to:// w w w .j ava 2s .c o m * The default cross-platform look and feel if the passed string is (case-insensitive) "Default", * The system look and feel if the passed string is (case-insensitive) "System", * The first look and feel found containing (case-insensitive) the string in its name (e.g. "Nimbus"), if any. * If the L&F specified is the current L&F, nothing will be done. * @param lookAndFeel */ public void setLookAndFeel(String lookAndFeel) { boolean changed = false; try { if ("default".equals(lookAndFeel.toLowerCase()) && !UIManager.getLookAndFeel().getClass().getName() .equals(UIManager.getCrossPlatformLookAndFeelClassName())) { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); changed = true; } else if ("system".equals(lookAndFeel.toLowerCase()) && !UIManager.getLookAndFeel().getClass() .getName().equals(UIManager.getSystemLookAndFeelClassName())) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); changed = true; } else { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lfs.length; i++) { if (lfs[i].getName().toLowerCase().contains(lookAndFeel.toLowerCase()) && !UIManager .getLookAndFeel().getName().toLowerCase().contains(lookAndFeel.toLowerCase())) { UIManager.setLookAndFeel(lfs[i].getClassName()); changed = true; break; } } } } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } if (changed) { SwingUtilities.updateComponentTreeUI(this); PuckConfiguration.getInstance().setProperty("look", lookAndFeel); } }
From source file:org.gcaldaemon.gui.ConfigEditor.java
private ConfigEditor(MainConfig config, ProgressMonitor monitor) throws Exception { this.config = config; try {//from ww w. j av a 2 s. c o m // Init swing System.setProperty("sun.awt.noerasebackground", "false"); //$NON-NLS-1$ //$NON-NLS-2$ System.setProperty("swing.aatext", "true"); //$NON-NLS-1$ //$NON-NLS-2$ System.setProperty("swing.boldMetal", "false"); //$NON-NLS-1$ //$NON-NLS-2$ Locale locale = Locale.getDefault(); String code = null; try { code = config.getConfigProperty(Configurator.EDITOR_LANGUAGE, null); if (code != null) { locale = new Locale(code); } } catch (Exception invalidLocale) { log.warn(invalidLocale); } if (!Messages.setUserLocale(locale)) { locale = Locale.ENGLISH; Messages.setUserLocale(locale); code = null; } if (code == null) { config.setConfigProperty(Configurator.EDITOR_LANGUAGE, locale.getLanguage().toLowerCase()); } try { boolean lookAndFeelChanged = false; String oldLaf = UIManager.getLookAndFeel().getClass().getName(); String newLaf = config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, UIManager.getCrossPlatformLookAndFeelClassName()); lookAndFeelChanged = !oldLaf.equals(newLaf); if (lookAndFeelChanged) { UIManager.setLookAndFeel(newLaf); } if (config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, null) == null) { config.setConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, newLaf); } if (lookAndFeelChanged) { new ConfigEditor(config, monitor); dispose(); return; } } catch (Exception invalidLaf) { log.warn(invalidLaf); } // Window settings setTitle(Messages.getString("config.editor") + " - " + config.getConfigPath()); //$NON-NLS-1$ //$NON-NLS-2$ setIconImage(TOOLKIT.getImage(ConfigEditor.class.getResource("/org/gcaldaemon/gui/icons/icon.gif"))); //$NON-NLS-1$ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); Container root = getContentPane(); root.setLayout(new BorderLayout()); root.add(folder, BorderLayout.CENTER); folder.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); folder.setTabPlacement(JTabbedPane.LEFT); folder.addChangeListener(this); status.setBorder(new BevelBorder(BevelBorder.LOWERED)); root.add(status, BorderLayout.SOUTH); // Create menu items fileMenu = new JMenu(Messages.getString("file")); //$NON-NLS-1$ saveMenu = new JMenuItem(Messages.getString("save"), getIcon("save")); //$NON-NLS-1$ //$NON-NLS-2$ exitMenu = new JMenuItem(Messages.getString("exit"), getIcon("exit")); //$NON-NLS-1$ //$NON-NLS-2$ viewMenu = new JMenu(Messages.getString("view")); //$NON-NLS-1$ langMenu = new JMenu(Messages.getString("language")); //$NON-NLS-1$ lafMenu = new JMenu(Messages.getString("look.and.feel")); //$NON-NLS-1$ transMenu = new JMenuItem(Messages.getString("translate")); //$NON-NLS-1$ logMenu = new JMenuItem(Messages.getString("log.viewer")); //$NON-NLS-1$ helpMenu = new JMenu(Messages.getString("help")); //$NON-NLS-1$ aboutMenu = new JMenuItem(Messages.getString("about")); //$NON-NLS-1$ // Build menu setJMenuBar(menuBar); menuBar.add(fileMenu); fileMenu.add(saveMenu); fileMenu.addSeparator(); fileMenu.add(exitMenu); menuBar.add(viewMenu); viewMenu.add(logMenu); viewMenu.addSeparator(); viewMenu.add(langMenu); viewMenu.add(lafMenu); langMenu.add(transMenu); menuBar.add(helpMenu); helpMenu.add(aboutMenu); // Build language menu Locale[] locales = Messages.getAvailableLocales(); String[] names = new String[locales.length]; String temp; int i; for (i = 0; i < locales.length; i++) { names[i] = locales[i].getDisplayLanguage(Locale.ENGLISH); if (names[i] == null || names[i].length() == 0) { names[i] = locales[i].getLanguage().toLowerCase(); } temp = locales[i].getDisplayLanguage(locale); if (temp != null && temp.length() > 0 && !temp.equals(names[i])) { names[i] = names[i] + " [" + temp + ']'; } } Arrays.sort(names, String.CASE_INSENSITIVE_ORDER); if (locales.length != 0) { langMenu.addSeparator(); } for (i = 0; i < locales.length; i++) { JMenuItem item = new JMenuItem(names[i]); item.setName('!' + names[i]); langMenu.add(item); item.addActionListener(this); } // Build look and feel menu LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); LookAndFeelInfo info; for (i = 0; i < infos.length; i++) { info = infos[i]; JMenuItem item = new JMenuItem(info.getName()); item.addActionListener(this); item.setName('#' + info.getClassName()); lafMenu.add(item); } // Action listeners addWindowListener(this); folder.addChangeListener(this); exitMenu.addActionListener(this); saveMenu.addActionListener(this); transMenu.addActionListener(this); logMenu.addActionListener(this); aboutMenu.addActionListener(this); // Add pages addPage("common.settings", new CommonPage(config, this)); //$NON-NLS-1$ addPage("http.settings", new HttpPage(config, this)); //$NON-NLS-1$ addPage("file.settings", new FilePage(config, this)); //$NON-NLS-1$ addPage("feed.settings", new FeedPage(config, this)); //$NON-NLS-1$ addPage("ldap.settings", new LdapPage(config, this)); //$NON-NLS-1$ addPage("notifier.settings", new NotifierPage(config, this)); //$NON-NLS-1$ addPage("sendmail.settings", new SendmailPage(config, this)); //$NON-NLS-1$ addPage("mailterm.settings", new MailtermPage(config, this)); //$NON-NLS-1$ // Set tab colors Iterator editors = disabledServices.iterator(); while (editors.hasNext()) { setServiceEnabled((BooleanEditor) editors.next(), false); } disabledServices = null; // Show GUI setResizable(true); Dimension size = TOOLKIT.getScreenSize(); int w = size.width - 50; int h = size.height - 70; w = Math.min(w, 1000); h = Math.min(h, 700); setSize(w, h); setLocation((size.width - w) / 2, (size.height - h) / 2); validate(); if (monitor != null) { monitor.dispose(); } setVisible(true); toFront(); } catch (Exception error) { if (monitor != null) { monitor.dispose(); } error(Messages.getString("error"), "Unable to start configurator: " + error, error); } }
From source file:org.intermine.install.swing.PreferencesDialog.java
/** * Initialise the look and feel choices by reading all the possible look and * feel names from <code>preferences.properties</code>, populating the combo * box accordingly and highlighting the last selected look and feel. *//*from w ww . j av a 2s . c o m*/ private void initLookAndFeels() { InputStream propsStream = getClass().getResourceAsStream("/org/intermine/install/preferences.properties"); if (propsStream == null) { throw new RuntimeException("The file 'preferences.properties' cannot be found on the class path."); } properties = new Properties(); try { try { properties.load(propsStream); } finally { propsStream.close(); } } catch (IOException e) { logger.warn("Could not load from preferences.properties. The options may be limited."); } String lookAndFeelNameList = properties.getProperty("lookandfeel.namelist", "Metal"); String[] lookAndFeelNames = lookAndFeelNameList.split(","); Arrays.sort(lookAndFeelNames, Collator.getInstance()); for (LookAndFeelInfo lf : UIManager.getInstalledLookAndFeels()) { installedLookAndFeels.put(lf.getName(), lf); } for (String lf : lookAndFeelNames) { lfComboModel.addElement(lf); } lfCombo.addActionListener(new LookAndFeelComboListener()); String lookAndFeel = MineManagerBackingStore.getInstance().getLookAndFeel(); if (StringUtils.isNotEmpty(lookAndFeel)) { lfCombo.setSelectedItem(lookAndFeel); } }
From source file:org.intermine.install.swing.ProjectEditor.java
/** * Get a look and feel by name, if it is supported on this platform. * * @param name The look and feel name.// www .ja va2 s . com * * @return The LookAndFeelInfo object if the named L&F is supported * on this platform, or null if not. */ public LookAndFeelInfo getLookAndFeelInfo(String name) { for (LookAndFeelInfo lfi : UIManager.getInstalledLookAndFeels()) { if (lfi.getName().equals(name)) { return lfi; } } return null; }