use of javax.swing.LookAndFeel in project qi4j-sdk by Qi4j.
the class Envisage method initLookAndFeel.
private void initLookAndFeel() {
String osName = System.getProperty("os.name").toUpperCase();
// set to use swing anti alias text only for JVM <= 1.5
System.setProperty("swing.aatext", "true");
// set default swing bold to false, only for JVM 1.5 or above
UIManager.put("swing.boldMetal", Boolean.FALSE);
// set LaF
LookAndFeel lnf = UIManager.getLookAndFeel();
if (lnf != null && lnf.getID().equalsIgnoreCase("Metal")) {
final String lnfClassName;
if (osName.startsWith("MAC")) {
//TODO i18n
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Envisage");
System.setProperty("apple.laf.useScreenMenuBar", "true");
lnfClassName = UIManager.getSystemLookAndFeelClassName();
} else if (osName.startsWith("WINDOWS")) {
UIManager.put("ClassLoader", LookUtils.class.getClassLoader());
lnfClassName = Options.getSystemLookAndFeelClassName();
Options.setUseNarrowButtons(false);
} else {
UIManager.put("ClassLoader", LookUtils.class.getClassLoader());
lnfClassName = Options.getCrossPlatformLookAndFeelClassName();
PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_METAL_VALUE);
PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
Options.setUseNarrowButtons(false);
//PlasticLookAndFeel.setMyCurrentTheme(new ExperienceBlueDefaultFont()); // for CJK Font
}
if (lnfClassName != null) {
try {
UIManager.setLookAndFeel(lnfClassName);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ex) {
System.err.println("Unable to set LookAndFeel, use default LookAndFeel.\n" + ex.getMessage());
}
}
}
}
use of javax.swing.LookAndFeel in project adempiere by adempiere.
the class PreviewPanel method setLFSelection.
/**
* Update the look list and theme list to show the current selection
*/
private void setLFSelection() {
m_setting = true;
// Search for PLAF
ValueNamePair plaf = null;
LookAndFeel lookFeel = UIManager.getLookAndFeel();
String look = lookFeel.getClass().getName();
for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
if (vp.getValue().equals(look)) {
plaf = vp;
break;
}
}
if (plaf != null)
lookList.setSelectedValue(plaf, true);
// Search for Theme
MetalTheme metalTheme = null;
ValueNamePair theme = null;
boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
themeList.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
if (metal) {
theme = null;
AppContext context = AppContext.getAppContext();
metalTheme = (MetalTheme) context.get("currentMetalTheme");
if (metalTheme != null) {
String lookTheme = metalTheme.getName();
for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
ValueNamePair vp = AdempierePLAF.getThemes()[i];
if (vp.getName().equals(lookTheme)) {
theme = vp;
break;
}
}
}
if (theme != null)
themeList.setSelectedValue(theme, true);
}
m_setting = false;
log.info(lookFeel + " - " + metalTheme);
}
use of javax.swing.LookAndFeel in project jdk8u_jdk by JetBrains.
the class DefaultTreeCellRenderer method getTreeCellRendererComponent.
/**
* Configures the renderer based on the passed in components.
* The value is set from messaging the tree with
* <code>convertValueToText</code>, which ultimately invokes
* <code>toString</code> on <code>value</code>.
* The foreground color is set based on the selection and the icon
* is set based on the <code>leaf</code> and <code>expanded</code>
* parameters.
*/
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, sel, expanded, leaf, row, hasFocus);
this.tree = tree;
this.hasFocus = hasFocus;
setText(stringValue);
Color fg = null;
isDropCell = false;
JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null && dropLocation.getChildIndex() == -1 && tree.getRowForPath(dropLocation.getPath()) == row) {
Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
if (col != null) {
fg = col;
} else {
fg = getTextSelectionColor();
}
isDropCell = true;
} else if (sel) {
fg = getTextSelectionColor();
} else {
fg = getTextNonSelectionColor();
}
setForeground(fg);
Icon icon = null;
if (leaf) {
icon = getLeafIcon();
} else if (expanded) {
icon = getOpenIcon();
} else {
icon = getClosedIcon();
}
if (!tree.isEnabled()) {
setEnabled(false);
LookAndFeel laf = UIManager.getLookAndFeel();
Icon disabledIcon = laf.getDisabledIcon(tree, icon);
if (disabledIcon != null)
icon = disabledIcon;
setDisabledIcon(icon);
} else {
setEnabled(true);
setIcon(icon);
}
setComponentOrientation(tree.getComponentOrientation());
selected = sel;
return this;
}
use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.
the class ThemeManager method buildLookAndFeelMenu.
/**
* Loads the menu with the available look and feels for the application
*
* @return l and f menu
*/
JMenu buildLookAndFeelMenu() {
String activeLookAndFeelName = UIManager.getLookAndFeel().getName();
// ButtonGroup buttonGroup = new ButtonGroup();
JMenu lfMenu = new JMenu();
lfMenu.setText(rb.getString("Menu.LookAndFeel.Name"));
lfMenu.add(buildSubstanceMenu());
List<String> lookAndFeels = new ArrayList<>();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (isLookAndFeelAvailable(info.getClassName())) {
lookAndFeels.add(info.getClassName());
}
}
for (String lookAndFeel : KNOWN) {
if (isLookAndFeelAvailable(lookAndFeel)) {
lookAndFeels.add(lookAndFeel);
}
}
Collections.sort(lookAndFeels);
for (String lookAndFeel : lookAndFeels) {
try {
Class<?> lnfClass = Class.forName(lookAndFeel);
LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance();
JRadioButtonMenuItem button = new JRadioButtonMenuItem();
button.setText(newLAF.getName());
button.setActionCommand(lookAndFeel);
button.setName(newLAF.getName());
button.addActionListener(e -> {
Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
pref.put(LF, e.getActionCommand());
restartUI();
});
lfButtonGroup.add(button);
lfMenu.add(button);
if (newLAF.getName().equals(activeLookAndFeelName)) {
button.setSelected(true);
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
}
}
return lfMenu;
}
use of javax.swing.LookAndFeel in project jgnash by ccavanaugh.
the class ThemeManager method getNimbusFontSize.
public static int getNimbusFontSize() {
Preferences p = Preferences.userNodeForPackage(ThemeManager.class);
int preferredSize = p.getInt(NIMBUS_FONT_SIZE, 0);
// and save it
if (preferredSize == 0) {
LookAndFeel old = UIManager.getLookAndFeel();
try {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
preferredSize = NimbusUtils.getBaseFontSize();
p.putInt(NIMBUS_FONT_SIZE, preferredSize);
UIManager.setLookAndFeel(old);
} catch (Exception e) {
Logger.getLogger(ThemeManager.class.getName()).log(Level.SEVERE, e.toString(), e);
}
}
return preferredSize;
}
Aggregations