List of utility methods to do Swing Look and Feel
boolean | isWindowsModernLookAndFeel() is Windows Modern Look And Feel if (!isWindowsXPLookAndFeel()) return false; String osName = System.getProperty("os.name"); return osName != null && (osName.contains("Windows 8") || osName.contains("Windows 10")); |
boolean | isWindowsUI() Check if we are using one of the Windows Look and Feels. return isWindowsNewUI() || isWindowsClassicUI();
|
boolean | isWindowsVistaLookAndFeel() Determines if current Look and Feel is Windows XP LookAndFeel. if (!isWindowsLookAndFeel()) { return false; boolean xpThemeActiveOS = Boolean.TRUE .equals(Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive")); boolean xpThemeDisabled = (System.getProperty("swing.noxp") != null); boolean vistaOs = System.getProperty("os.version").startsWith("6.0"); return ((xpThemeActiveOS) && (!xpThemeDisabled) && vistaOs); ... |
boolean | isWindowsXPLookAndFeel() Determines if current L&F is Windows XP LookAndFeel if (!isWindowsLookAndFeel()) { return false; boolean xpThemeActiveOS = Boolean.TRUE .equals(Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive")); boolean xpThemeDisabled = (System.getProperty("swing.noxp") != null); boolean vistaOs = System.getProperty("os.version").startsWith("6.0"); return ((xpThemeActiveOS) && (!xpThemeDisabled) && !vistaOs); ... |
boolean | isWinLAF() is Win LAF return UIManager.getLookAndFeel() != null && "Windows".equals(UIManager.getLookAndFeel().getID()); |
boolean | isWinLAF() is Win LAF return UIManager.getLookAndFeel() != null && "Windows".equals(UIManager.getLookAndFeel().getName()); |
boolean | isXP() is XP if (isWindows()) { Boolean b = (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive"); if (b != null && b) return true; return false; |
void | listLookAndFeels() list Look And Feels LookAndFeelInfo[] lafs = javax.swing.UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo laf : lafs) { System.out.println(String.format("%s: %s", laf.getName(), laf.getClassName())); |
void | lookAndFeelDefault(String style) look And Feel Default try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (style.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } catch (Exception e) { ... |
void | lookLikeSystem() Sets the GUI to look like the systems standard GUI. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); ... |