KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > IconUIResource


1 /*
2  * @(#)IconUIResource.java 1.14 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 import java.awt.Component JavaDoc;
11 import java.awt.Graphics JavaDoc;
12 import java.io.Serializable JavaDoc;
13 import javax.swing.Icon JavaDoc;
14 import javax.swing.plaf.UIResource JavaDoc;
15
16 /*
17  * An Icon wrapper class which implements UIResource. UI
18  * classes which set icon properties should use this class
19  * to wrap any icons specified as defaults.
20  *
21  * This class delegates all method invocations to the
22  * Icon "delegate" object specified at construction.
23  * <p>
24  * <strong>Warning:</strong>
25  * Serialized objects of this class will not be compatible with
26  * future Swing releases. The current serialization support is
27  * appropriate for short term storage or RMI between applications running
28  * the same version of Swing. As of 1.4, support for long term storage
29  * of all JavaBeans<sup><font size="-2">TM</font></sup>
30  * has been added to the <code>java.beans</code> package.
31  * Please see {@link java.beans.XMLEncoder}.
32  *
33  * @see javax.swing.plaf.UIResource
34  * @version 1.14 12/19/03
35  * @author Amy Fowler
36  *
37  */

38 public class IconUIResource implements Icon JavaDoc, UIResource JavaDoc, Serializable JavaDoc
39 {
40     private Icon JavaDoc delegate;
41
42     /**
43      * Creates a UIResource icon object which wraps
44      * an existing Icon instance.
45      * @param delegate the icon being wrapped
46      */

47     public IconUIResource(Icon JavaDoc delegate) {
48         if (delegate == null) {
49             throw new IllegalArgumentException JavaDoc("null delegate icon argument");
50         }
51         this.delegate = delegate;
52     }
53
54     public void paintIcon(Component JavaDoc c, Graphics JavaDoc g, int x, int y) {
55         delegate.paintIcon(c, g, x, y);
56     }
57
58     public int getIconWidth() {
59         return delegate.getIconWidth();
60     }
61
62     public int getIconHeight() {
63         return delegate.getIconHeight();
64     }
65  
66 }
67
Popular Tags