public static String getSystemLookAndFeelClassName() { if (systemLaFClassName != null) { return systemLaFClassName; } else if (SystemInfo.isLinux) { // Normally, GTK LaF is considered "system" when: // 1) Gnome session is run // 2) gtk lib is available // Here we weaken the requirements to only 2) and force GTK LaF // installation in order to let it properly scale default font // based on Xft.dpi value. try { String name = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; Class cls = Class.forName(name); LookAndFeel laf = (LookAndFeel) cls.newInstance(); if (laf.isSupportedLookAndFeel()) { // if gtk lib is available return systemLaFClassName = name; } } catch (Exception ignore) { } } return systemLaFClassName = UIManager.getSystemLookAndFeelClassName(); }
public static void installLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { LookAndFeel plaf; plaf = (LookAndFeel)Class.forName(className, true, ExtensionManager.getClassLoader()).newInstance(); if(plaf.isSupportedLookAndFeel()) UIManager.installLookAndFeel(plaf.getName(), plaf.getClass().getName()); }
try {return ((LookAndFeel)c.newInstance()).isSupportedLookAndFeel();} catch(Throwable e) { LOGGER.debug("Caught exception", e);
/** * Creates a menu item for the given look and feel information */ private JMenuItem createLookAndFeelMenuItem(DefaultLookAndFeelManager lfm, LookAndFeelInfo lfinfo) { String desc = lfinfo.getName(); String class_name = lfinfo.getLookAndFeelClassName(); if (desc == null || desc.length() == 0) desc = class_name; /** * add a counter to the description to make sure the action command for * the menu is unique. it is possible to get the same description for a * look and feel */ String actioncmd = lfinfo.getId(); assert (actioncmd != null); JMenuItem item = i18n_createMenuItem(desc, actioncmd, null); m_lfmenu.add(item); assert (getComponentByName(actioncmd) == item); LookAndFeel lf = lfinfo.getLookAndFeel(); if (lf == null || !lf.isSupportedLookAndFeel()) { item.setEnabled(false); } m_controller.assignAction(actioncmd, m_controller.m_lfaction); return item; }