use of javax.swing.UnsupportedLookAndFeelException in project jdk8u_jdk by JetBrains.
the class ColorCustomizationTest method main.
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
new ColorCustomizationTest().test();
}
});
}
use of javax.swing.UnsupportedLookAndFeelException in project jabref by JabRef.
the class JabRefGUI method setLookAndFeel.
private void setLookAndFeel() {
try {
String lookFeel;
String systemLookFeel = UIManager.getSystemLookAndFeelClassName();
if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) {
// See https://github.com/JabRef/jabref/issues/393, https://github.com/JabRef/jabref/issues/638
if (System.getProperty("java.runtime.name").contains("OpenJDK")) {
// Metal L&F
lookFeel = UIManager.getCrossPlatformLookAndFeelClassName();
LOGGER.warn("There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution.");
} else {
lookFeel = systemLookFeel;
}
} else {
lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL);
}
// FIXME: Open JDK problem
if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel) && !System.getProperty("java.runtime.name").contains("OpenJDK")) {
// try to avoid ending up with the ugly Metal L&F
Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel();
MetalLookAndFeel.setCurrentTheme(new SkyBluer());
com.jgoodies.looks.Options.setPopupDropShadowEnabled(true);
UIManager.setLookAndFeel(lnf);
} else {
try {
UIManager.setLookAndFeel(lookFeel);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
// specified look and feel does not exist on the classpath, so use system l&f
UIManager.setLookAndFeel(systemLookFeel);
// also set system l&f as default
Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLookFeel);
// notify the user
JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(), Localization.lang("Unable to find the requested look and feel and thus the default one is used."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);
LOGGER.warn("Unable to find requested look and feel", e);
}
}
} catch (Exception e) {
LOGGER.warn("Look and feel could not be set", e);
}
// In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms
boolean overrideDefaultFonts = Globals.prefs.getBoolean(JabRefPreferences.OVERRIDE_DEFAULT_FONTS);
if (overrideDefaultFonts) {
int fontSize = Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE);
UIDefaults defaults = UIManager.getDefaults();
Enumeration<Object> keys = defaults.keys();
for (Object key : Collections.list(keys)) {
if ((key instanceof String) && ((String) key).endsWith(".font")) {
FontUIResource font = (FontUIResource) UIManager.get(key);
font = new FontUIResource(font.getName(), font.getStyle(), fontSize);
defaults.put(key, font);
}
}
}
}
use of javax.swing.UnsupportedLookAndFeelException in project jgnash by ccavanaugh.
the class ThemeManager method setLookAndFeel.
private static void setLookAndFeel(final String lookAndFeel) {
Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
String theme = pref.get(THEME, DEFAULT_THEME);
try {
Class<?> lafClass = Class.forName(lookAndFeel);
Object lafInstance = lafClass.newInstance();
if (lafInstance instanceof SubstanceSkin) {
UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE);
if (isSubstanceAnimationsEnabled()) {
AnimationConfigurationManager.getInstance().setTimelineDuration(animationDuration);
} else {
AnimationConfigurationManager.getInstance().setTimelineDuration(0);
}
SubstanceLookAndFeel.setSkin(lookAndFeel);
} else if (lafInstance instanceof NimbusLookAndFeel) {
UIManager.setLookAndFeel((LookAndFeel) lafInstance);
NimbusUtils.changeFontSize(getNimbusFontSize());
} else if (lafInstance instanceof MetalLookAndFeel) {
UIManager.setLookAndFeel((LookAndFeel) lafInstance);
setTheme(theme);
} else if (lafInstance instanceof LookAndFeel) {
UIManager.setLookAndFeel((LookAndFeel) lafInstance);
}
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
}
}
Aggregations