/** * 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. * * <p>The L&F menu will use this method to detemine whether the various L&F options should be * active or inactive. */ 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; } }
/** * 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. * * <p>The Look and Feel menu will use this method to determine whether the various Look and Feel * options should be active or inactive. * * @param laf name of look and feel to search for * @return true if found */ @SuppressWarnings("rawtypes") private static boolean isLookAndFeelAvailable(final String laf) { try { Class lnfClass = Class.forName(laf); LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance(); return newLAF.isSupportedLookAndFeel(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { // If ANYTHING bad happens, return false Logger.getLogger(ThemeManager.class.getName()).log(Level.FINEST, e.getLocalizedMessage(), e); return false; } }