use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.
the class ThemeManager method buildSubstanceMenu.
private JMenu buildSubstanceMenu() {
LookAndFeel lf = UIManager.getLookAndFeel();
JMenu substanceMenu = new JMenu(rb.getString("Menu.SubstanceThemes.Name"));
for (SkinInfo info : SubstanceLookAndFeel.getAllSkins().values()) {
JRadioButtonMenuItem button = new JRadioButtonMenuItem();
button.setText(info.getDisplayName());
button.setActionCommand(info.getClassName());
// add the button to the global look and feel
lfButtonGroup.add(button);
button.addActionListener(e -> {
Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
pref.put(LF, e.getActionCommand());
restartUI();
});
substanceMenu.add(button);
// select the button as the active L&F if it is the current skin
if (lf instanceof SubstanceLookAndFeel) {
if (SubstanceLookAndFeel.getCurrentSkin().getClass().getName().equals(info.getClassName())) {
button.setSelected(true);
}
}
}
return substanceMenu;
}
use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.
the class ThemeManager method isLookAndFeelAvailable.
/**
* 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;
}
}
use of javax.swing.LookAndFeel 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);
}
}
use of javax.swing.LookAndFeel in project 111mil-funes by cperezabo.
the class AgendaContactos method main.
public static void main(String[] args) {
try {
LookAndFeel laf = UIManager.getLookAndFeel();
if ("Metal".equals(laf.getName())) {
String className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
UIManager.setLookAndFeel(className);
}
} catch (Exception e) {
//No importa
}
PantallaListadoContactos pantalla = new PantallaListadoContactos();
pantalla.setVisible(true);
}
use of javax.swing.LookAndFeel in project 111mil-funes by cperezabo.
the class Tateti method main.
public static void main(String[] args) {
try {
LookAndFeel laf = UIManager.getLookAndFeel();
if ("Metal".equals(laf.getName())) {
String className = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
UIManager.setLookAndFeel(className);
}
} catch (Exception e) {
//No importa
}
Tablero tablero = new Tablero();
tablero.setVisible(true);
}
Aggregations