/** Returns whether the current LAF is Metal Steel. */ protected static boolean isMetalSteel() { if (!UIManager.getLookAndFeel().getName().equals("Metal")) { return false; } try { LookAndFeel laf = UIManager.getLookAndFeel(); laf.getClass().getMethod("getCurrentTheme", new Class[0]); return false; } catch (Exception e) { } return true; }
/** * @param className * @throws Exception */ public static void setLookAndFeel(String className) throws Exception { LookAndFeel laf = null; if (!className.equals(DEFAULT_LAF)) { if (className.equals(SYSTEM_LAF)) { String systemLaf = UIManager.getSystemLookAndFeelClassName(); log.debug("System Look And Feel is " + systemLaf); laf = (LookAndFeel) Class.forName(systemLaf).newInstance(); } else if (className.equals(CROSS_PLATFORM_LAF)) { String crossPlatformLaf = UIManager.getCrossPlatformLookAndFeelClassName(); log.debug("Cross Platform Look And Feel is " + crossPlatformLaf); laf = (LookAndFeel) Class.forName(crossPlatformLaf).newInstance(); } else { laf = (LookAndFeel) Class.forName(className).newInstance(); } } // Now actually set the look and feel if (laf != null) { log.info("Setting look and feel " + laf.getName() + " (" + laf.getClass().getName() + ")"); UIManager.setLookAndFeel(laf); UIManager.put("EditorPane.font", UIManager.getFont("TextArea.font")); } }
public boolean isCurrentLookAndFeel() { LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel(); if (currentLookAndFeel == null) return false; return lookAndFeel.getClass().getName().equals(currentLookAndFeel.getClass().getName()); }