1 /* 2 * @(#)UIResource.java 1.10 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package javax.swing.plaf; 9 10 11 /** 12 * This interface is used to mark objects created by ComponentUI delegates. 13 * The <code>ComponentUI.installUI()</code> and 14 * <code>ComponentUI.uninstallUI()</code> methods can use this interface 15 * to decide if a properties value has been overridden. For example, the 16 * JList cellRenderer property is initialized by BasicListUI.installUI(), 17 * only if it's initial value is null: 18 * <pre> 19 * if (list.getCellRenderer() == null) { 20 * list.setCellRenderer((ListCellRenderer)(UIManager.get("List.cellRenderer"))); 21 * } 22 * </pre> 23 * At uninstallUI() time we reset the property to null if its value 24 * is an instance of UIResource: 25 * <pre> 26 * if (list.getCellRenderer() instanceof UIResource) { 27 * list.setCellRenderer(null); 28 * } 29 *</pre> 30 * This pattern applies to all properties except the java.awt.Component 31 * properties font, foreground, and background. If one of these 32 * properties isn't initialized, or is explicitly set to null, 33 * its container provides the value. For this reason the 34 * <code>"== null"</code> is unreliable when installUI() is called 35 * to dynamically change a components look and feel. So at installUI() 36 * time we check to see if the current value is a UIResource: 37 *<pre> 38 * if (!(list.getFont() instanceof UIResource)) { 39 * list.setFont(UIManager.getFont("List.font")); 40 * } 41 * </pre> 42 * 43 * @see ComponentUI 44 * @version 1.10 12/19/03 45 * @author Hans Muller 46 * 47 */ 48 49 public interface UIResource { 50 } 51