本文整理汇总了Java中javax.swing.UIManager.getDefaults方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getDefaults方法的具体用法?Java UIManager.getDefaults怎么用?Java UIManager.getDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.UIManager
的用法示例。
在下文中一共展示了UIManager.getDefaults方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTreeCellRendererComponent
import javax.swing.UIManager; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
this.label.setIcon(DEFAULT_NODE_ICON);
this.label.setText(value.toString());
if (value instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getUserObject() instanceof IconTreeListItem) {
IconTreeListItem iconItem = (IconTreeListItem) node.getUserObject();
this.label.setText(iconItem.getUserObject().toString());
if (iconItem.getIcon() != null) {
this.label.setIcon(iconItem.getIcon());
} else if (iconItem.getUserObject() instanceof Prop) {
Prop prop = (Prop) iconItem.getUserObject();
label.setIcon(getIcon(prop));
}
}
}
UIDefaults defaults = UIManager.getDefaults();
this.label.setOpaque(true);
this.label.setBackground(hasFocus || selected ? defaults.getColor("Tree.selectionBackground") : defaults.getColor("Tree.background"));
this.label.setForeground(hasFocus || selected ? defaults.getColor("Tree.selectionForeground") : defaults.getColor("Tree.foreground"));
this.label.setBorder(hasFocus ? focusBorder : normalBorder);
return label;
}
示例2: initSwingConstants
import javax.swing.UIManager; //导入方法依赖的package包/类
/** Initialized fields used in Swing Palette. */
private static void initSwingConstants() {
if (swingColorNames != null)
return;
UIDefaults def = UIManager.getDefaults ();
Enumeration e = def.keys ();
java.util.TreeSet<String> names = new java.util.TreeSet<String>();
while (e.hasMoreElements ()) {
Object k = e.nextElement ();
if (! (k instanceof String))
continue;
Object v = def.get (k);
if (! (v instanceof Color))
continue;
names.add((String)k);
}
swingColorNames = new String [names.size ()];
names.toArray(swingColorNames);
swingColors = new Color [swingColorNames.length];
int i, k = swingColorNames.length;
for (i = 0; i < k; i++)
swingColors [i] = (Color) def.get (swingColorNames [i]);
}
示例3: run
import javax.swing.UIManager; //导入方法依赖的package包/类
public void run() {
UIDefaults uidef = UIManager.getDefaults();
synchronized (uidef) {
blocking = true;
sleep();
}
}
示例4: install
import javax.swing.UIManager; //导入方法依赖的package包/类
private static void install() {
// don't install directory chooser if standard chooser is desired
if (isStandardChooserForced()) {
return;
}
final UIDefaults uid = UIManager.getDefaults();
originalImpl = (Class<?>) uid.getUIClass(KEY);
Class<?> impl = DelegatingChooserUI.class;
final String val = impl.getName();
// don't install dirchooser if quickfilechooser is present
if (!isQuickFileChooser(uid.get(KEY))) {
uid.put(KEY, val);
// To make it work in NetBeans too:
uid.put(val, impl);
}
// #61147: prevent NB from switching to a different UI later (under GTK):
uid.addPropertyChangeListener(pcl = new PropertyChangeListener() {
public @Override void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
Object className = uid.get(KEY);
if ((name.equals(KEY) || name.equals("UIDefaults")) && !val.equals(className)
&& !isQuickFileChooser(className)) {
originalImpl = (Class<?>) uid.getUIClass(KEY);
uid.put(KEY, val);
}
}
});
}
示例5: installFont
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* Set the default font in all UI elements.
*
* @param defaultFont A {@code Font} to use by default.
*/
public static void installFont(Font defaultFont) {
UIDefaults u = UIManager.getDefaults();
java.util.Enumeration<Object> keys = u.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (u.get(key) instanceof javax.swing.plaf.FontUIResource) {
u.put(key, defaultFont);
}
}
}
示例6: Bug6530694
import javax.swing.UIManager; //导入方法依赖的package包/类
Bug6530694() {
Locale.setDefault(Locale.GERMANY);
UIDefaults defs = UIManager.getDefaults();
defs.addResourceBundle("Bug6530694");
String str = defs.getString("testkey");
if (!"testvalue".equals(str)) {
throw new RuntimeException("Could not load the resource for de_DE locale");
}
}