-
- 所有已知实现类:
-
ActionMapUIResource
,BasicBorders.ButtonBorder
,BasicBorders.FieldBorder
,BasicBorders.MarginBorder
,BasicBorders.MenuBarBorder
,BasicBorders.RadioButtonBorder
,BasicBorders.RolloverButtonBorder
,BasicBorders.SplitPaneBorder
,BasicBorders.ToggleButtonBorder
,BasicComboBoxEditor.UIResource
,BasicComboBoxRenderer.UIResource
,BasicTextUI.BasicCaret
,BasicTextUI.BasicHighlighter
,BorderUIResource
,BorderUIResource.BevelBorderUIResource
,BorderUIResource.CompoundBorderUIResource
,BorderUIResource.EmptyBorderUIResource
,BorderUIResource.EtchedBorderUIResource
,BorderUIResource.LineBorderUIResource
,BorderUIResource.MatteBorderUIResource
,BorderUIResource.TitledBorderUIResource
,ColorUIResource
,ComponentInputMapUIResource
,DefaultListCellRenderer.UIResource
,DefaultMenuLayout
,DefaultTableCellRenderer.UIResource
,DimensionUIResource
,FontUIResource
,IconUIResource
,InputMapUIResource
,InsetsUIResource
,JScrollPane.ScrollBar
,MetalBorders.ButtonBorder
,MetalBorders.Flush3DBorder
,MetalBorders.InternalFrameBorder
,MetalBorders.MenuBarBorder
,MetalBorders.MenuItemBorder
,MetalBorders.OptionDialogBorder
,MetalBorders.PaletteBorder
,MetalBorders.PopupMenuBorder
,MetalBorders.RolloverButtonBorder
,MetalBorders.ScrollPaneBorder
,MetalBorders.TextFieldBorder
,MetalBorders.ToggleButtonBorder
,MetalBorders.ToolBarBorder
,MetalCheckBoxIcon
,MetalComboBoxEditor.UIResource
,MetalIconFactory.PaletteCloseIcon
,ScrollPaneLayout.UIResource
public interface UIResource
此接口用于标记由ComponentUI委托创建的对象。ComponentUI.installUI()
和ComponentUI.uninstallUI()
方法可以使用此接口来决定属性值是否已被覆盖。 例如,JList cellRenderer属性由BasicListUI.installUI()初始化,只有当它的初始值为null时:if (list.getCellRenderer() == null) { list.setCellRenderer((ListCellRenderer)(UIManager.get("List.cellRenderer"))); }
在uninstallUI()时间,如果该值为UIResource的实例,则将该属性重置为nullif (list.getCellRenderer() instanceof UIResource) { list.setCellRenderer(null); }
此模式适用于除java.awt.Component属性字体,前景和背景之外的所有属性。 如果这些属性之一未初始化,或者显式设置为null,则其容器将提供该值。 为此,当调用installUI()来动态更改组件外观时,"== null"
是不可靠的。 所以在installUI()时候,我们检查当前值是否是UIResource:if (!(list.getFont() instanceof UIResource)) { list.setFont(UIManager.getFont("List.font")); }
- 另请参见:
-
ComponentUI