private static boolean isOceanTheme() { if (!inSandbox) { try { java.lang.reflect.Field field = MetalLookAndFeel.class.getDeclaredField("currentTheme"); field.setAccessible(true); Object theme = field.get(null); return "javax.swing.plaf.metal.OceanTheme".equals(theme.getClass().getName()); } catch (Exception ex) { // We're in a sandbox and can't access the field inSandbox = true; } } if (!checkedForOcean) { checkedForOcean = true; checkForOcean(); } return usingOcean; }