58 |
58 |
59 protected int thickness; |
59 protected int thickness; |
60 protected Color lineColor; |
60 protected Color lineColor; |
61 protected boolean roundedCorners; |
61 protected boolean roundedCorners; |
62 |
62 |
63 /** Convenience method for getting the Color.black LineBorder of thickness 1. |
63 /** |
64 */ |
64 * Convenience method for getting the Color.black LineBorder of thickness 1. |
|
65 * |
|
66 * @return a {@code LineBorder} with {@code Color.black} and thickness of 1 |
|
67 */ |
65 public static Border createBlackLineBorder() { |
68 public static Border createBlackLineBorder() { |
66 if (blackLine == null) { |
69 if (blackLine == null) { |
67 blackLine = new LineBorder(Color.black, 1); |
70 blackLine = new LineBorder(Color.black, 1); |
68 } |
71 } |
69 return blackLine; |
72 return blackLine; |
70 } |
73 } |
71 |
74 |
72 /** Convenience method for getting the Color.gray LineBorder of thickness 1. |
75 /** |
73 */ |
76 * Convenience method for getting the Color.gray LineBorder of thickness 1. |
|
77 * |
|
78 * @return a {@code LineBorder} with {@code Color.gray} and thickness of 1 |
|
79 */ |
74 public static Border createGrayLineBorder() { |
80 public static Border createGrayLineBorder() { |
75 if (grayLine == null) { |
81 if (grayLine == null) { |
76 grayLine = new LineBorder(Color.gray, 1); |
82 grayLine = new LineBorder(Color.gray, 1); |
77 } |
83 } |
78 return grayLine; |
84 return grayLine; |
79 } |
85 } |
80 |
86 |
81 /** |
87 /** |
82 * Creates a line border with the specified color and a |
88 * Creates a line border with the specified color and a |
83 * thickness = 1. |
89 * thickness = 1. |
|
90 * |
84 * @param color the color for the border |
91 * @param color the color for the border |
85 */ |
92 */ |
86 public LineBorder(Color color) { |
93 public LineBorder(Color color) { |
87 this(color, 1, false); |
94 this(color, 1, false); |
88 } |
95 } |
89 |
96 |
90 /** |
97 /** |
91 * Creates a line border with the specified color and thickness. |
98 * Creates a line border with the specified color and thickness. |
|
99 * |
92 * @param color the color of the border |
100 * @param color the color of the border |
93 * @param thickness the thickness of the border |
101 * @param thickness the thickness of the border |
94 */ |
102 */ |
95 public LineBorder(Color color, int thickness) { |
103 public LineBorder(Color color, int thickness) { |
96 this(color, thickness, false); |
104 this(color, thickness, false); |
97 } |
105 } |
98 |
106 |
99 /** |
107 /** |
100 * Creates a line border with the specified color, thickness, |
108 * Creates a line border with the specified color, thickness, |
101 * and corner shape. |
109 * and corner shape. |
|
110 * |
102 * @param color the color of the border |
111 * @param color the color of the border |
103 * @param thickness the thickness of the border |
112 * @param thickness the thickness of the border |
104 * @param roundedCorners whether or not border corners should be round |
113 * @param roundedCorners whether or not border corners should be round |
105 * @since 1.3 |
114 * @since 1.3 |
106 */ |
115 */ |
112 } |
121 } |
113 |
122 |
114 /** |
123 /** |
115 * Paints the border for the specified component with the |
124 * Paints the border for the specified component with the |
116 * specified position and size. |
125 * specified position and size. |
|
126 * |
117 * @param c the component for which this border is being painted |
127 * @param c the component for which this border is being painted |
118 * @param g the paint graphics |
128 * @param g the paint graphics |
119 * @param x the x position of the painted border |
129 * @param x the x position of the painted border |
120 * @param y the y position of the painted border |
130 * @param y the y position of the painted border |
121 * @param width the width of the painted border |
131 * @param width the width of the painted border |
150 } |
160 } |
151 } |
161 } |
152 |
162 |
153 /** |
163 /** |
154 * Reinitialize the insets parameter with this Border's current Insets. |
164 * Reinitialize the insets parameter with this Border's current Insets. |
|
165 * |
155 * @param c the component for which this border insets value applies |
166 * @param c the component for which this border insets value applies |
156 * @param insets the object to be reinitialized |
167 * @param insets the object to be reinitialized |
157 */ |
168 */ |
158 public Insets getBorderInsets(Component c, Insets insets) { |
169 public Insets getBorderInsets(Component c, Insets insets) { |
159 insets.set(thickness, thickness, thickness, thickness); |
170 insets.set(thickness, thickness, thickness, thickness); |
160 return insets; |
171 return insets; |
161 } |
172 } |
162 |
173 |
163 /** |
174 /** |
164 * Returns the color of the border. |
175 * Returns the color of the border. |
|
176 * |
|
177 * @return a {@code Color} object representing the color of this object |
165 */ |
178 */ |
166 public Color getLineColor() { |
179 public Color getLineColor() { |
167 return lineColor; |
180 return lineColor; |
168 } |
181 } |
169 |
182 |
170 /** |
183 /** |
171 * Returns the thickness of the border. |
184 * Returns the thickness of the border. |
|
185 * |
|
186 * @return the thickness of this border |
172 */ |
187 */ |
173 public int getThickness() { |
188 public int getThickness() { |
174 return thickness; |
189 return thickness; |
175 } |
190 } |
176 |
191 |
177 /** |
192 /** |
178 * Returns whether this border will be drawn with rounded corners. |
193 * Returns whether this border will be drawn with rounded corners. |
|
194 * |
|
195 * @return {@code true} if this border should have rounded corners |
179 * @since 1.3 |
196 * @since 1.3 |
180 */ |
197 */ |
181 public boolean getRoundedCorners() { |
198 public boolean getRoundedCorners() { |
182 return roundedCorners; |
199 return roundedCorners; |
183 } |
200 } |
184 |
201 |
185 /** |
202 /** |
186 * Returns whether or not the border is opaque. |
203 * Returns whether or not the border is opaque. |
|
204 * |
|
205 * @return {@code true} if the border is opaque, {@code false} otherwise |
187 */ |
206 */ |
188 public boolean isBorderOpaque() { |
207 public boolean isBorderOpaque() { |
189 return !roundedCorners; |
208 return !roundedCorners; |
190 } |
209 } |
191 |
210 |