本文整理匯總了Java中javax.swing.UIDefaults.getUI方法的典型用法代碼示例。如果您正苦於以下問題:Java UIDefaults.getUI方法的具體用法?Java UIDefaults.getUI怎麽用?Java UIDefaults.getUI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.UIDefaults
的用法示例。
在下文中一共展示了UIDefaults.getUI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createUIs
import javax.swing.UIDefaults; //導入方法依賴的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;
}