KickJava   Java API By Example, From Geeks To Geeks.

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


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

45 public class BorderUIResource implements Border, UIResource JavaDoc, Serializable JavaDoc
46 {
47     static Border etched;
48     static Border loweredBevel;
49     static Border raisedBevel;
50     static Border blackLine;
51
52     public static Border getEtchedBorderUIResource() {
53         if (etched == null) {
54             etched = new EtchedBorderUIResource();
55         }
56         return etched;
57     }
58
59     public static Border getLoweredBevelBorderUIResource() {
60         if (loweredBevel == null) {
61             loweredBevel = new BevelBorderUIResource(BevelBorder.LOWERED);
62         }
63         return loweredBevel;
64     }
65
66     public static Border getRaisedBevelBorderUIResource() {
67         if (raisedBevel == null) {
68             raisedBevel = new BevelBorderUIResource(BevelBorder.RAISED);
69         }
70         return raisedBevel;
71     }
72
73     public static Border getBlackLineBorderUIResource() {
74         if (blackLine == null) {
75             blackLine = new LineBorderUIResource(Color.black);
76         }
77         return blackLine;
78     }
79
80     private Border delegate;
81
82     /**
83      * Creates a UIResource border object which wraps
84      * an existing Border instance.
85      * @param delegate the border being wrapped
86      */

87     public BorderUIResource(Border delegate) {
88         if (delegate == null) {
89             throw new IllegalArgumentException JavaDoc("null border delegate argument");
90         }
91         this.delegate = delegate;
92     }
93
94     public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
95                             int width, int height) {
96         delegate.paintBorder(c, g, x, y, width, height);
97     }
98
99     public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
100         return delegate.getBorderInsets(c);
101     }
102
103     public boolean isBorderOpaque() {
104         return delegate.isBorderOpaque();
105     }
106
107     public static class CompoundBorderUIResource extends CompoundBorder implements UIResource JavaDoc {
108         public CompoundBorderUIResource(Border outsideBorder, Border insideBorder) {
109             super(outsideBorder, insideBorder);
110         }
111
112     }
113
114     public static class EmptyBorderUIResource extends EmptyBorder implements UIResource JavaDoc {
115
116         public EmptyBorderUIResource(int top, int left, int bottom, int right) {
117             super(top, left, bottom, right);
118         }
119         public EmptyBorderUIResource(Insets JavaDoc insets) {
120             super(insets);
121         }
122     }
123
124     public static class LineBorderUIResource extends LineBorder implements UIResource JavaDoc {
125
126         public LineBorderUIResource(Color JavaDoc color) {
127             super(color);
128         }
129
130         public LineBorderUIResource(Color JavaDoc color, int thickness) {
131             super(color, thickness);
132         }
133     }
134
135
136     public static class BevelBorderUIResource extends BevelBorder implements UIResource JavaDoc {
137
138         public BevelBorderUIResource(int bevelType) {
139             super(bevelType);
140         }
141
142         public BevelBorderUIResource(int bevelType, Color JavaDoc highlight, Color JavaDoc shadow) {
143             super(bevelType, highlight, shadow);
144         }
145
146         public BevelBorderUIResource(int bevelType,
147                                      Color JavaDoc highlightOuter, Color JavaDoc highlightInner,
148                                      Color JavaDoc shadowOuter, Color JavaDoc shadowInner) {
149             super(bevelType, highlightOuter, highlightInner, shadowOuter, shadowInner);
150         }
151     }
152
153     public static class EtchedBorderUIResource extends EtchedBorder implements UIResource JavaDoc {
154
155         public EtchedBorderUIResource() {
156             super();
157         }
158
159         public EtchedBorderUIResource(int etchType) {
160             super(etchType);
161         }
162
163         public EtchedBorderUIResource(Color JavaDoc highlight, Color JavaDoc shadow) {
164             super(highlight, shadow);
165         }
166
167         public EtchedBorderUIResource(int etchType, Color JavaDoc highlight, Color JavaDoc shadow) {
168             super(etchType, highlight, shadow);
169         }
170     }
171
172     public static class MatteBorderUIResource extends MatteBorder implements UIResource JavaDoc {
173
174         public MatteBorderUIResource(int top, int left, int bottom, int right,
175                                      Color JavaDoc color) {
176             super(top, left, bottom, right, color);
177         }
178
179         public MatteBorderUIResource(int top, int left, int bottom, int right,
180                                      Icon JavaDoc tileIcon) {
181             super(top, left, bottom, right, tileIcon);
182         }
183
184         public MatteBorderUIResource(Icon JavaDoc tileIcon) {
185             super(tileIcon);
186         }
187     }
188
189     public static class TitledBorderUIResource extends TitledBorder implements UIResource JavaDoc {
190
191         public TitledBorderUIResource(String JavaDoc title) {
192             super(title);
193         }
194
195         public TitledBorderUIResource(Border border) {
196             super(border);
197         }
198         
199         public TitledBorderUIResource(Border border, String JavaDoc title) {
200             super(border, title);
201         }
202
203         public TitledBorderUIResource(Border border,
204                         String JavaDoc title,
205                         int titleJustification,
206                         int titlePosition) {
207             super(border, title, titleJustification, titlePosition);
208         }
209
210         public TitledBorderUIResource(Border border,
211                         String JavaDoc title,
212                         int titleJustification,
213                         int titlePosition,
214                         Font JavaDoc titleFont) {
215             super(border, title, titleJustification, titlePosition, titleFont);
216         }
217
218         public TitledBorderUIResource(Border border,
219                         String JavaDoc title,
220                         int titleJustification,
221                         int titlePosition,
222                         Font JavaDoc titleFont,
223                         Color JavaDoc titleColor) {
224             super(border, title, titleJustification, titlePosition, titleFont, titleColor);
225         }
226     }
227  
228 }
229
Popular Tags