List of usage examples for javax.swing UIManager getLookAndFeel
public static LookAndFeel getLookAndFeel()
null
. From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java
public static boolean isUnderGTKLookAndFeel() { return UIManager.getLookAndFeel().getName().contains("GTK"); }
From source file:DefaultsDisplay.java
/** Creates a new instance of DefaultsDisplayer */ public DefaultsDisplay() { defaultsTablesMap = new HashMap<String, JComponent>(); try {//from w w w. ja va 2s . com UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (System.getProperty("os.name").equals("Mac OS X")) { OSXLookAndFeelName = UIManager.getLookAndFeel().getName(); } } catch (Exception ex) { // better work :-) } setLayout(new BorderLayout()); JPanel controls = new JPanel(); controls.add(createLookAndFeelControl()); controls.add(createFilterControl()); add(controls, BorderLayout.NORTH); tabPane = new JTabbedPane(); add(tabPane, BorderLayout.CENTER); addDefaultsTab(); }
From source file:SimplelookandfeelExample.java
public void updateState() { String lnfName = UIManager.getLookAndFeel().getClass().getName(); if (lnfName.indexOf(metal) >= 0) { metalButton.setSelected(true);/*from w ww . ja v a2 s.c om*/ } else if (lnfName.indexOf(windows) >= 0) { windowsButton.setSelected(true); } else if (lnfName.indexOf(motif) >= 0) { motifButton.setSelected(true); } else { System.err.println("SimpleExample is using an unknown L&F: " + lnfName); } }
From source file:net.sf.housekeeper.swing.ApplicationPresenter.java
/** * Initializes the Look and Feel.//from w ww . jav a 2 s . c om */ private void initLookAndFeel() { if (SystemUtils.IS_OS_MAC_OSX) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { //Do nothing if setting the Look and Feel fails. } } else { try { UIManager.setLookAndFeel(new PlasticXPLookAndFeel()); } catch (Exception e) { //Do nothing if setting the Look and Feel fails. } } LOG.debug("Using Look and Feel: " + UIManager.getLookAndFeel().getName()); }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private JMenu createViewMenu() { JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic('v'); JMenu lnfMenu = new JMenu("Look and Feel"); lnfMenu.setMnemonic('f'); ButtonGroup lnfGroup = new ButtonGroup(); LookAndFeelInfo lnfs[] = UIManager.getInstalledLookAndFeels(); String lnfCurrentName = null; LookAndFeel lnfCurrent = UIManager.getLookAndFeel(); if (lnfCurrent != null) { lnfCurrentName = lnfCurrent.getClass().getName(); }/*from w w w . j a v a2s. co m*/ UISwitcher switcher = new UISwitcher(); for (int i = 0; i < lnfs.length; i++) { JRadioButtonMenuItem lnfItem = new JRadioButtonMenuItem(lnfs[i].getName()); lnfItem.addActionListener(switcher); lnfItem.setActionCommand(lnfs[i].getClassName()); lnfGroup.add(lnfItem); lnfMenu.add(lnfItem); if (lnfs[i].getClassName().equals(lnfCurrentName)) { lnfGroup.setSelected(lnfItem.getModel(), true); } } viewMenu.add(lnfMenu); return viewMenu; }
From source file:DefaultsDisplay.java
protected JComponent createLookAndFeelControl() { JPanel panel = new JPanel(); JLabel label = new JLabel("Current Look and Feel"); lookAndFeelComboBox = new JComboBox(); label.setLabelFor(lookAndFeelComboBox); panel.add(label);/*w w w .ja v a2 s . c o m*/ panel.add(lookAndFeelComboBox); // Look for toolkit look and feels first UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels(); lookAndFeelsMap = new HashMap<String, String>(); for (UIManager.LookAndFeelInfo info : lookAndFeelInfos) { String name = info.getName(); // workaround for problem where Info and name property don't match on OS X if (name.equals("Mac OS X")) { name = OSXLookAndFeelName; } // workaround for bug where Nimbus classname is incorrect lookAndFeelsMap.put(name, name.equals("Nimbus") ? "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" : info.getClassName()); lookAndFeelComboBox.addItem(name); } lookAndFeelComboBox.setSelectedItem(UIManager.getLookAndFeel().getName()); lookAndFeelComboBox.addActionListener(new ChangeLookAndFeelAction()); return panel; }
From source file:LayeredPaneDemo.java
public static ComponentUI createUI(JComponent c) { LookAndFeel currentLF = UIManager.getLookAndFeel(); if (frameUI == null) frameUI = new InnerFrameUI(); try {//from w w w . j a v a 2 s.c o m frameUI.installDefaults(); InnerFrame frame = (InnerFrame) c; frame.setBorder(DEFAULT_INNER_FRAME_BORDER); if (frame.isShowing()) frame.repaint(); } catch (Exception ex) { System.err.println(ex); ex.printStackTrace(); } return frameUI; }
From source file:DefaultsDisplay.java
protected void addDefaultsTab() { LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); JScrollPane scrollPane = new JScrollPane(createDefaultsTable()); tabPane.addTab(lookAndFeel.getName() + " Defaults", scrollPane); defaultsTablesMap.put(lookAndFeel.getName(), scrollPane); }
From source file:net.pms.newgui.LooksFrame.java
public static void initializeLookAndFeel() { synchronized (lookAndFeelInitializedLock) { if (lookAndFeelInitialized) { return; }//from ww w . ja v a 2 s. c o m if (Platform.isWindows()) { try { UIManager.setLookAndFeel(WINDOWS_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Windows look and feel: ", e); } } else if (System.getProperty("nativelook") == null && !Platform.isMac()) { try { UIManager.setLookAndFeel(PLASTICXP_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Plastic XP look and feel: ", e); } } else { try { String systemClassName = UIManager.getSystemLookAndFeelClassName(); // Workaround for Gnome try { String gtkLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; Class.forName(gtkLAF); if (systemClassName.equals("javax.swing.plaf.metal.MetalLookAndFeel")) { systemClassName = gtkLAF; } } catch (ClassNotFoundException ce) { LOGGER.error("Error loading GTK look and feel: ", ce); } LOGGER.trace("Choosing Java look and feel: " + systemClassName); UIManager.setLookAndFeel(systemClassName); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { try { UIManager.setLookAndFeel(PLASTICXP_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Plastic XP look and feel: ", e); } LOGGER.error("Error while setting native look and feel: ", e1); } } if (isParticularLaFSet(UIManager.getLookAndFeel(), PLASTICXP_LNF)) { PlasticLookAndFeel.setPlasticTheme(PlasticLookAndFeel.createMyDefaultTheme()); PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_DEFAULT_VALUE); PlasticLookAndFeel.setHighContrastFocusColorsEnabled(false); } else if (isParticularLaFSet(UIManager.getLookAndFeel(), METAL_LNF)) { MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); } // Work around caching in MetalRadioButtonUI JRadioButton radio = new JRadioButton(); radio.getUI().uninstallUI(radio); JCheckBox checkBox = new JCheckBox(); checkBox.getUI().uninstallUI(checkBox); // Workaround for JDK-8179014: JFileChooser with Windows look and feel crashes on win 10 // https://bugs.openjdk.java.net/browse/JDK-8179014 if (isParticularLaFSet(UIManager.getLookAndFeel(), WINDOWS_LNF)) { UIManager.put("FileChooser.useSystemExtensionHiding", false); } lookAndFeelInitialized = true; } }