47 |
import java.awt.AWTError; |
import java.awt.AWTError; |
48 |
|
|
49 |
/** |
/** |
50 |
* Needs some work I guess.... |
* A component that uses a {@link BoxLayout} as Layout Manager. |
51 |
|
* |
52 |
|
* In addition to that, this class provides a set of static methods for |
53 |
|
* creating some filler components ('struts' and 'glue') for use in |
54 |
|
* containers that are laid out using BoxLayout. |
55 |
* |
* |
56 |
* @author Ronald Veldema (rveldema@cs.vu.nl) |
* @author Ronald Veldema (rveldema@cs.vu.nl) |
57 |
*/ |
*/ |
73 |
return null; |
return null; |
74 |
} |
} |
75 |
} |
} |
76 |
|
|
77 |
|
/** |
78 |
|
* A component that servers as a filler in BoxLayout controlled containers. |
79 |
|
*/ |
80 |
public static class Filler extends JComponent implements Accessible |
public static class Filler extends JComponent implements Accessible |
81 |
{ |
{ |
82 |
private static final long serialVersionUID = -1204263191910183998L; |
private static final long serialVersionUID = -1204263191910183998L; |
100 |
|
|
101 |
private transient Dimension min, pref, max; |
private transient Dimension min, pref, max; |
102 |
|
|
103 |
|
/** |
104 |
|
* Creates a new instance of Filler. |
105 |
|
* |
106 |
|
* @param min the minimum size of the filler. |
107 |
|
* @param pref the preferred size of the filler. |
108 |
|
* @param max the maximum size of the filler. |
109 |
|
*/ |
110 |
public Filler(Dimension min, Dimension pref, Dimension max) |
public Filler(Dimension min, Dimension pref, Dimension max) |
111 |
{ |
{ |
112 |
changeShape(min, pref, max); |
changeShape(min, pref, max); |
113 |
} |
} |
114 |
|
|
115 |
|
/** |
116 |
|
* Changes the dimensions of this Filler. |
117 |
|
* |
118 |
|
* @param min the new minimum size of the filler. |
119 |
|
* @param pref the new preferred size of the filler. |
120 |
|
* @param max the new maximum size of the filler. |
121 |
|
*/ |
122 |
public void changeShape(Dimension min, Dimension pref, Dimension max) |
public void changeShape(Dimension min, Dimension pref, Dimension max) |
123 |
{ |
{ |
124 |
this.min = min; |
this.min = min; |
134 |
return accessibleContext; |
return accessibleContext; |
135 |
} |
} |
136 |
|
|
137 |
|
/** |
138 |
|
* Returns the maximum size of this Filler. |
139 |
|
* |
140 |
|
* @return the maximum size of this Filler. |
141 |
|
*/ |
142 |
public Dimension getMaximumSize() |
public Dimension getMaximumSize() |
143 |
{ |
{ |
144 |
return max; |
return max; |
145 |
} |
} |
146 |
|
|
147 |
|
/** |
148 |
|
* Returns the minimum size of this Filler. |
149 |
|
* |
150 |
|
* @return the minimum size of this Filler. |
151 |
|
*/ |
152 |
public Dimension getMinimumSize() |
public Dimension getMinimumSize() |
153 |
{ |
{ |
154 |
return min; |
return min; |
155 |
} |
} |
156 |
|
|
157 |
|
/** |
158 |
|
* Returns the preferred size of this Filler. |
159 |
|
* |
160 |
|
* @return the preferred size of this Filler. |
161 |
|
*/ |
162 |
public Dimension getPreferredSize() |
public Dimension getPreferredSize() |
163 |
{ |
{ |
164 |
return pref; |
return pref; |
165 |
} |
} |
166 |
} |
} |
167 |
|
|
168 |
|
/** |
169 |
|
* Creates a new Box component, that lays out its children according |
170 |
|
* to the <code>axis</code> parameter. |
171 |
|
* |
172 |
|
* @param axis the orientation of the BoxLayout. |
173 |
|
* |
174 |
|
* @see BoxLayout#X_AXIS |
175 |
|
* @see BoxLayout#Y_AXIS |
176 |
|
* @see BoxLayout#LINE_AXIS |
177 |
|
* @see BoxLayout#PAGE_AXIS |
178 |
|
*/ |
179 |
public Box(int axis) |
public Box(int axis) |
180 |
{ |
{ |
181 |
setLayout(new BoxLayout(this, axis)); |
setLayout(new BoxLayout(this, axis)); |
182 |
} |
} |
183 |
|
|
184 |
|
/** |
185 |
|
* Creates a filler component which acts as glue between components. |
186 |
|
* It does not take space unless some extra space is available. If extra |
187 |
|
* space is available, this component can expand in both X and Y directions. |
188 |
|
* |
189 |
|
* @return a glue-like filler component. |
190 |
|
*/ |
191 |
public static Component createGlue() |
public static Component createGlue() |
192 |
{ |
{ |
193 |
return null; |
Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0), |
194 |
|
new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE) |
195 |
|
); |
196 |
|
return glue; |
197 |
} |
} |
198 |
|
|
199 |
public static Box createHorizontalBox() |
public static Box createHorizontalBox() |
201 |
return null; |
return null; |
202 |
} |
} |
203 |
|
|
204 |
|
/** |
205 |
|
* Creates a filler component which acts as glue between components. |
206 |
|
* It does not take space unless some extra space is available. If extra |
207 |
|
* space is available, this component can expand in the X direction. |
208 |
|
* |
209 |
|
* @return a glue-like filler component. |
210 |
|
*/ |
211 |
public static Component createHorizontalGlue() |
public static Component createHorizontalGlue() |
212 |
{ |
{ |
213 |
return null; |
return createGlue(); |
214 |
} |
} |
215 |
|
|
216 |
|
/** |
217 |
|
* Creates a filler component which acts as strut between components. |
218 |
|
* It will fill exactly the specified horizontal size. |
219 |
|
* |
220 |
|
* @param width the width of this strut in pixels. |
221 |
|
* |
222 |
|
* @return a strut-like filler component. |
223 |
|
*/ |
224 |
public static Component createHorizontalStrut(int width) |
public static Component createHorizontalStrut(int width) |
225 |
{ |
{ |
226 |
return null; |
Filler strut = new Filler(new Dimension(width, 0), |
227 |
|
new Dimension(width, 0), |
228 |
|
new Dimension(width, Integer.MAX_VALUE)); |
229 |
|
return strut; |
230 |
} |
} |
231 |
|
|
232 |
public static Component createRigidArea(Dimension d) |
public static Component createRigidArea(Dimension d) |
239 |
return null; |
return null; |
240 |
} |
} |
241 |
|
|
242 |
|
/** |
243 |
|
* Creates a filler component which acts as glue between components. |
244 |
|
* It does not take space unless some extra space is available. If extra |
245 |
|
* space is available, this component can expand in the Y direction. |
246 |
|
* |
247 |
|
* @return a glue-like filler component. |
248 |
|
*/ |
249 |
public static Component createVerticalGlue() |
public static Component createVerticalGlue() |
250 |
{ |
{ |
251 |
return null; |
return createGlue(); |
252 |
} |
} |
253 |
|
|
254 |
|
/** |
255 |
|
* Creates a filler component which acts as strut between components. |
256 |
|
* It will fill exactly the specified vertical size. |
257 |
|
* |
258 |
|
* @param height the height of this strut in pixels. |
259 |
|
* |
260 |
|
* @return a strut-like filler component. |
261 |
|
*/ |
262 |
public static Component createVerticalStrut(int height) |
public static Component createVerticalStrut(int height) |
263 |
{ |
{ |
264 |
return null; |
Filler strut = new Filler(new Dimension(0, height), |
265 |
|
new Dimension(0, height), |
266 |
|
new Dimension(Integer.MAX_VALUE, height)); |
267 |
|
return strut; |
268 |
} |
} |
269 |
|
|
270 |
public void setLayout(LayoutManager l) |
public void setLayout(LayoutManager l) |