KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > BorderFactory


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4  
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7  
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9  
10    $Log: BorderFactory.java,v $
11    Revision 1.1 2004/01/26 14:05:23 bobintetley
12    Compatibility methods
13
14  
15  */

16
17 package swingwtx.swing;
18
19 import swingwtx.swing.border.*;
20 import swingwt.awt.*;
21
22 public abstract class BorderFactory {
23     
24     public static Border createLineBorder(Color color) {
25         return new LineBorder(color, 1);
26     }
27     public static Border createLineBorder(Color color, int thickness) {
28         return new LineBorder(color, thickness);
29     }
30     
31     static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED);
32     static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED);
33     
34     public static Border createRaisedBevelBorder() {
35         return createSharedBevel(BevelBorder.RAISED);
36     }
37     public static Border createLoweredBevelBorder() {
38         return createSharedBevel(BevelBorder.LOWERED);
39     }
40     public static Border createBevelBorder(int type) {
41         return createSharedBevel(type);
42     }
43     public static Border createBevelBorder(int type, Color highlight, Color shadow) {
44         return new BevelBorder(type, highlight, shadow);
45     }
46     public static Border createBevelBorder(int type,
47     Color highlightOuter, Color highlightInner,
48     Color shadowOuter, Color shadowInner) {
49         return new BevelBorder(type, highlightOuter, highlightInner,
50         shadowOuter, shadowInner);
51     }
52     static Border createSharedBevel(int type) {
53         if(type == BevelBorder.RAISED) {
54             return sharedRaisedBevel;
55         } else if(type == BevelBorder.LOWERED) {
56             return sharedLoweredBevel;
57         }
58         return null;
59     }
60     
61     static final Border sharedEtchedBorder = new EtchedBorder();
62     private static Border sharedRaisedEtchedBorder;
63     
64     public static Border createEtchedBorder() {
65         return sharedEtchedBorder;
66     }
67     public static Border createEtchedBorder(Color highlight, Color shadow) {
68         return new EtchedBorder(highlight, shadow);
69     }
70     public static Border createEtchedBorder(int type) {
71         switch (type) {
72             case EtchedBorder.RAISED:
73                 if (sharedRaisedEtchedBorder == null) {
74                     sharedRaisedEtchedBorder = new EtchedBorder
75                     (EtchedBorder.RAISED);
76                 }
77                 return sharedRaisedEtchedBorder;
78             case EtchedBorder.LOWERED:
79                 return sharedEtchedBorder;
80             default:
81                 throw new IllegalArgumentException JavaDoc("Invalid type");
82         }
83     }
84     public static Border createEtchedBorder(int type, Color highlight,
85     Color shadow) {
86         return new EtchedBorder(type, highlight, shadow);
87     }
88     public static TitledBorder createTitledBorder(String JavaDoc title) {
89         return new TitledBorder(title);
90     }
91     public static TitledBorder createTitledBorder(Border border) {
92         return new TitledBorder(border);
93     }
94     public static TitledBorder createTitledBorder(Border border,
95     String JavaDoc title) {
96         return new TitledBorder(border, title);
97     }
98     public static TitledBorder createTitledBorder(Border border,
99     String JavaDoc title,
100     int titleJustification,
101     int titlePosition) {
102         return new TitledBorder(border, title, titleJustification,
103         titlePosition);
104     }
105     public static TitledBorder createTitledBorder(Border border,
106     String JavaDoc title,
107     int titleJustification,
108     int titlePosition,
109     Font titleFont) {
110         return new TitledBorder(border, title, titleJustification,
111         titlePosition, titleFont);
112     }
113     public static TitledBorder createTitledBorder(Border border,
114     String JavaDoc title,
115     int titleJustification,
116     int titlePosition,
117     Font titleFont,
118     Color titleColor) {
119         return new TitledBorder(border, title, titleJustification,
120         titlePosition, titleFont, titleColor);
121     }
122     final static Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
123     public static Border createEmptyBorder() {
124         return emptyBorder;
125     }
126     public static Border createEmptyBorder(int top, int left,
127     int bottom, int right) {
128         return new EmptyBorder(top, left, bottom, right);
129     }
130     public static CompoundBorder createCompoundBorder() {
131         return new CompoundBorder();
132     }
133     public static CompoundBorder createCompoundBorder(Border outsideBorder,
134     Border insideBorder) {
135         return new CompoundBorder(outsideBorder, insideBorder);
136     }
137     public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,
138     Color color) {
139         return new MatteBorder(top, left, bottom, right, color);
140     }
141     public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,
142     Icon tileIcon) {
143         return new MatteBorder(top, left, bottom, right, tileIcon);
144     }
145 }
146
147
Popular Tags