本文整理汇总了Java中javax.swing.LookAndFeel.getDefaults方法的典型用法代码示例。如果您正苦于以下问题:Java LookAndFeel.getDefaults方法的具体用法?Java LookAndFeel.getDefaults怎么用?Java LookAndFeel.getDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.LookAndFeel
的用法示例。
在下文中一共展示了LookAndFeel.getDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initUIDefaults
import javax.swing.LookAndFeel; //导入方法依赖的package包/类
static void initUIDefaults() {
try {
// Load Defaults from MotifLookAndFeel
// This dummy load is necessary to get SystemColor initialized. !!!!!!
Color c = SystemColor.text;
LookAndFeel lnf = new XAWTLookAndFeel();
uidefaults = lnf.getDefaults();
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例2: createUIs
import javax.swing.LookAndFeel; //导入方法依赖的package包/类
/**
* Creates the UI delegates for the <code>target</code> component and
* returns a multiplexing UI delegate (<code>mui</code>) if there are
* multiple delegates.
*
* @param mui a multiplexing UI delegate appropriate for the component.
* @param uis a vector into which the UI delegates will be added.
* @param target the target component.
*
* @return A UI delegate.
*/
public static ComponentUI createUIs(ComponentUI mui, Vector uis,
JComponent target)
{
// get primary UI delegate for 'target', and add it to uis
ComponentUI ui = null;
LookAndFeel primary = UIManager.getLookAndFeel();
if (primary != null)
{
ui = UIManager.getUI(target);
uis.add(ui);
}
// for any auxiliary look and feels in use, get the UI delegate and add
// it to uis
LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels();
for (int i = 0; i < auxlafs.length; i++)
{
LookAndFeel auxlaf = auxlafs[i];
// FIXME: here I call getDefaults() to get the UI delegate from the
// auxiliary look and feel. But getDefaults() creates a new set of
// defaults every time it is called, which is wasteful. Unfortunately
// I cannot find another way to get the UI delegate, so I'm doing it
// anyway...
UIDefaults defaults = auxlaf.getDefaults();
ui = defaults.getUI(target);
if (ui != null)
uis.add(ui);
}
// if uis contains more than 1 delegate, return mui, otherwise return
// the primary delegate
if (uis.size() > 1)
return mui;
else
return ui;
}