List of utility methods to do Swing UIManager
void | printDefaults() Convenience method to print all the UI settings to System.out. UIDefaults defaults = UIManager.getDefaults(); Enumeration<Object> keys = defaults.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); System.out.println(key + ": " + defaults.get(key)); |
void | printUIDefaults() print UI Defaults UIDefaults uiDefaults = UIManager.getDefaults(); Enumeration<Object> e = uiDefaults.keys(); while (e.hasMoreElements()) { Object key = e.nextElement(); Object val = uiDefaults.get(key); System.out.println("[" + key.toString() + "]:[" + (null != val ? val.toString() : "(null)") + "]"); |
boolean | setComponentLF(JComponent comp, String ui) set Component LF LookAndFeel previousLF = UIManager.getLookAndFeel(); try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (ui.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; comp.updateUI(); UIManager.setLookAndFeel(previousLF); } catch (Exception e) { return false; return true; |
void | setCrossPlatformProperties() set Cross Platform Properties if (System.getProperty("os.name").startsWith("Mac")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { |
void | setDefaultSize(int size) set Default Size Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet(); Object[] keys = keySet.toArray(new Object[keySet.size()]); for (Object key : keys) { if (key != null && key.toString().toLowerCase().contains("font")) { System.out.println(key); Font font = UIManager.getDefaults().getFont(key); if (font != null) { font = font.deriveFont((float) size); ... |
void | setEnabled(Component component, boolean enabled, boolean recursively) set Enabled component.setEnabled(enabled); if (component instanceof JLabel) { Color color = enabled ? getLabelForeground() : getLabelDisabledForeground(); if (color != null) { component.setForeground(color); if (recursively && enabled == component.isEnabled()) { ... |
void | setNative() Sets the default LAF. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { |
boolean | SetNetBeansCompatibleUIManager() Set the application look-and-feel to match NetBeans. UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); int lafno = 3; try { UIManager.setLookAndFeel(info[lafno].getClassName()); } catch (Exception e) { System.err.println("Couldn't load " + info[lafno].getClassName() + " look and feel " + e); return false; return true; |
boolean | setNimbusLF() Sets look and feel to Nimbus. try { for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(laf.getName())) { UIManager.setLookAndFeel(laf.getClassName()); break; } catch (Exception e) { ... |
void | setSwingProperties(String appName) set Swing Properties UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder()); System.setProperty("com.apple.mrj.application.apple.menu.about.name", appName); System.setProperty("apple.laf.useScreenMenuBar", "true"); |