-
- 所有已知实现类:
-
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的实例,我们将该属性重置为null:if (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