public interface UIResource 
      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,则其容器将提供该值。 
       因此, "== null" installUI()来动态更改组件外观时,"== null"是不可靠的。 
       所以在installUI()时候,我们检查当前值是否是UIResource: 
         if (!(list.getFont() instanceof UIResource)) {
     list.setFont(UIManager.getFont("List.font"));
 }  
      ComponentUI 
        Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.