Java Code Examples for javax.swing.LookAndFeel#isSupportedLookAndFeel()
The following examples show how to use
javax.swing.LookAndFeel#isSupportedLookAndFeel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PLAF.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * */ private void addToMenu(String name, String className, JMenu menu) { logger.debug("PLAF LookAndFeelInfo {}", className); boolean isSupported = true; try { Class cl = Class.forName(className); LookAndFeel lf = (LookAndFeel) cl.newInstance(); if (!lf.isSupportedLookAndFeel()) { isSupported = false; } } catch (Throwable t) { isSupported = false; } AbstractAction act = new PLAFAction(name, className); JMenuItem mi = menu.add(act); if (!isSupported) { mi.setEnabled(false); } }
Example 2
Source File: SwingSet2.java From beautyeye with Apache License 2.0 | 3 votes |
/** * A utility function that layers on top of the LookAndFeel's * isSupportedLookAndFeel() method. Returns true if the LookAndFeel * is supported. Returns false if the LookAndFeel is not supported * and/or if there is any kind of error checking if the LookAndFeel * is supported. * * The L&F menu will use this method to detemine whether the various * L&F options should be active or inactive. * * @param laf the laf * @return true, if is available look and feel */ protected boolean isAvailableLookAndFeel(String laf) { try { Class lnfClass = Class.forName(laf); LookAndFeel newLAF = (LookAndFeel)(lnfClass.newInstance()); return newLAF.isSupportedLookAndFeel(); } catch(Exception e) { // If ANYTHING weird happens, return false return false; } }