71 * <tr ALIGN=CENTER>
72 * <td>Figure 1: Horizontal, Left-to-Right</td>
73 *
74 * <td>Figure 2: Horizontal, Right-to-Left</td>
75 * </tr>
76 * </table>
77 * <p>
78 * When both the number of rows and the number of columns have
79 * been set to non-zero values, either by a constructor or
80 * by the <tt>setRows</tt> and <tt>setColumns</tt> methods, the number of
81 * columns specified is ignored. Instead, the number of
82 * columns is determined from the specified number of rows
83 * and the total number of components in the layout. So, for
84 * example, if three rows and two columns have been specified
85 * and nine components are added to the layout, they will
86 * be displayed as three rows of three columns. Specifying
87 * the number of columns affects the layout only when the
88 * number of rows is set to zero.
89 *
90 * @author Arthur van Hoff
91 * @since JDK1.0
92 */
93 public class GridLayout implements LayoutManager, java.io.Serializable {
94 /*
95 * serialVersionUID
96 */
97 private static final long serialVersionUID = -7411804673224730901L;
98
99 /**
100 * This is the horizontal gap (in pixels) which specifies the space
101 * between columns. They can be changed at any time.
102 * This should be a non-negative integer.
103 *
104 * @serial
105 * @see #getHgap()
106 * @see #setHgap(int)
107 */
108 int hgap;
109 /**
110 * This is the vertical gap (in pixels) which specifies the space
111 * between rows. They can be changed at any time.
127 * @see #getRows()
128 * @see #setRows(int)
129 */
130 int rows;
131 /**
132 * This is the number of columns specified for the grid. The number
133 * of columns can be changed at any time.
134 * This should be a non negative integer, where '0' means
135 * 'any number' meaning that the number of Columns in that
136 * dimension depends on the other dimension.
137 *
138 * @serial
139 * @see #getColumns()
140 * @see #setColumns(int)
141 */
142 int cols;
143
144 /**
145 * Creates a grid layout with a default of one column per component,
146 * in a single row.
147 * @since JDK1.1
148 */
149 public GridLayout() {
150 this(1, 0, 0, 0);
151 }
152
153 /**
154 * Creates a grid layout with the specified number of rows and
155 * columns. All components in the layout are given equal size.
156 * <p>
157 * One, but not both, of <code>rows</code> and <code>cols</code> can
158 * be zero, which means that any number of objects can be placed in a
159 * row or in a column.
160 * @param rows the rows, with the value zero meaning
161 * any number of rows.
162 * @param cols the columns, with the value zero meaning
163 * any number of columns.
164 */
165 public GridLayout(int rows, int cols) {
166 this(rows, cols, 0, 0);
167 }
186 * any number of columns
187 * @param hgap the horizontal gap
188 * @param vgap the vertical gap
189 * @exception IllegalArgumentException if the value of both
190 * <code>rows</code> and <code>cols</code> is
191 * set to zero
192 */
193 public GridLayout(int rows, int cols, int hgap, int vgap) {
194 if ((rows == 0) && (cols == 0)) {
195 throw new IllegalArgumentException("rows and cols cannot both be zero");
196 }
197 this.rows = rows;
198 this.cols = cols;
199 this.hgap = hgap;
200 this.vgap = vgap;
201 }
202
203 /**
204 * Gets the number of rows in this layout.
205 * @return the number of rows in this layout
206 * @since JDK1.1
207 */
208 public int getRows() {
209 return rows;
210 }
211
212 /**
213 * Sets the number of rows in this layout to the specified value.
214 * @param rows the number of rows in this layout
215 * @exception IllegalArgumentException if the value of both
216 * <code>rows</code> and <code>cols</code> is set to zero
217 * @since JDK1.1
218 */
219 public void setRows(int rows) {
220 if ((rows == 0) && (this.cols == 0)) {
221 throw new IllegalArgumentException("rows and cols cannot both be zero");
222 }
223 this.rows = rows;
224 }
225
226 /**
227 * Gets the number of columns in this layout.
228 * @return the number of columns in this layout
229 * @since JDK1.1
230 */
231 public int getColumns() {
232 return cols;
233 }
234
235 /**
236 * Sets the number of columns in this layout to the specified value.
237 * Setting the number of columns has no affect on the layout
238 * if the number of rows specified by a constructor or by
239 * the <tt>setRows</tt> method is non-zero. In that case, the number
240 * of columns displayed in the layout is determined by the total
241 * number of components and the number of rows specified.
242 * @param cols the number of columns in this layout
243 * @exception IllegalArgumentException if the value of both
244 * <code>rows</code> and <code>cols</code> is set to zero
245 * @since JDK1.1
246 */
247 public void setColumns(int cols) {
248 if ((cols == 0) && (this.rows == 0)) {
249 throw new IllegalArgumentException("rows and cols cannot both be zero");
250 }
251 this.cols = cols;
252 }
253
254 /**
255 * Gets the horizontal gap between components.
256 * @return the horizontal gap between components
257 * @since JDK1.1
258 */
259 public int getHgap() {
260 return hgap;
261 }
262
263 /**
264 * Sets the horizontal gap between components to the specified value.
265 * @param hgap the horizontal gap between components
266 * @since JDK1.1
267 */
268 public void setHgap(int hgap) {
269 this.hgap = hgap;
270 }
271
272 /**
273 * Gets the vertical gap between components.
274 * @return the vertical gap between components
275 * @since JDK1.1
276 */
277 public int getVgap() {
278 return vgap;
279 }
280
281 /**
282 * Sets the vertical gap between components to the specified value.
283 * @param vgap the vertical gap between components
284 * @since JDK1.1
285 */
286 public void setVgap(int vgap) {
287 this.vgap = vgap;
288 }
289
290 /**
291 * Adds the specified component with the specified name to the layout.
292 * @param name the name of the component
293 * @param comp the component to be added
294 */
295 public void addLayoutComponent(String name, Component comp) {
296 }
297
298 /**
299 * Removes the specified component from the layout.
300 * @param comp the component to be removed
301 */
302 public void removeLayoutComponent(Component comp) {
303 }
304
|
71 * <tr ALIGN=CENTER>
72 * <td>Figure 1: Horizontal, Left-to-Right</td>
73 *
74 * <td>Figure 2: Horizontal, Right-to-Left</td>
75 * </tr>
76 * </table>
77 * <p>
78 * When both the number of rows and the number of columns have
79 * been set to non-zero values, either by a constructor or
80 * by the <tt>setRows</tt> and <tt>setColumns</tt> methods, the number of
81 * columns specified is ignored. Instead, the number of
82 * columns is determined from the specified number of rows
83 * and the total number of components in the layout. So, for
84 * example, if three rows and two columns have been specified
85 * and nine components are added to the layout, they will
86 * be displayed as three rows of three columns. Specifying
87 * the number of columns affects the layout only when the
88 * number of rows is set to zero.
89 *
90 * @author Arthur van Hoff
91 * @since 1.0
92 */
93 public class GridLayout implements LayoutManager, java.io.Serializable {
94 /*
95 * serialVersionUID
96 */
97 private static final long serialVersionUID = -7411804673224730901L;
98
99 /**
100 * This is the horizontal gap (in pixels) which specifies the space
101 * between columns. They can be changed at any time.
102 * This should be a non-negative integer.
103 *
104 * @serial
105 * @see #getHgap()
106 * @see #setHgap(int)
107 */
108 int hgap;
109 /**
110 * This is the vertical gap (in pixels) which specifies the space
111 * between rows. They can be changed at any time.
127 * @see #getRows()
128 * @see #setRows(int)
129 */
130 int rows;
131 /**
132 * This is the number of columns specified for the grid. The number
133 * of columns can be changed at any time.
134 * This should be a non negative integer, where '0' means
135 * 'any number' meaning that the number of Columns in that
136 * dimension depends on the other dimension.
137 *
138 * @serial
139 * @see #getColumns()
140 * @see #setColumns(int)
141 */
142 int cols;
143
144 /**
145 * Creates a grid layout with a default of one column per component,
146 * in a single row.
147 * @since 1.1
148 */
149 public GridLayout() {
150 this(1, 0, 0, 0);
151 }
152
153 /**
154 * Creates a grid layout with the specified number of rows and
155 * columns. All components in the layout are given equal size.
156 * <p>
157 * One, but not both, of <code>rows</code> and <code>cols</code> can
158 * be zero, which means that any number of objects can be placed in a
159 * row or in a column.
160 * @param rows the rows, with the value zero meaning
161 * any number of rows.
162 * @param cols the columns, with the value zero meaning
163 * any number of columns.
164 */
165 public GridLayout(int rows, int cols) {
166 this(rows, cols, 0, 0);
167 }
186 * any number of columns
187 * @param hgap the horizontal gap
188 * @param vgap the vertical gap
189 * @exception IllegalArgumentException if the value of both
190 * <code>rows</code> and <code>cols</code> is
191 * set to zero
192 */
193 public GridLayout(int rows, int cols, int hgap, int vgap) {
194 if ((rows == 0) && (cols == 0)) {
195 throw new IllegalArgumentException("rows and cols cannot both be zero");
196 }
197 this.rows = rows;
198 this.cols = cols;
199 this.hgap = hgap;
200 this.vgap = vgap;
201 }
202
203 /**
204 * Gets the number of rows in this layout.
205 * @return the number of rows in this layout
206 * @since 1.1
207 */
208 public int getRows() {
209 return rows;
210 }
211
212 /**
213 * Sets the number of rows in this layout to the specified value.
214 * @param rows the number of rows in this layout
215 * @exception IllegalArgumentException if the value of both
216 * <code>rows</code> and <code>cols</code> is set to zero
217 * @since 1.1
218 */
219 public void setRows(int rows) {
220 if ((rows == 0) && (this.cols == 0)) {
221 throw new IllegalArgumentException("rows and cols cannot both be zero");
222 }
223 this.rows = rows;
224 }
225
226 /**
227 * Gets the number of columns in this layout.
228 * @return the number of columns in this layout
229 * @since 1.1
230 */
231 public int getColumns() {
232 return cols;
233 }
234
235 /**
236 * Sets the number of columns in this layout to the specified value.
237 * Setting the number of columns has no affect on the layout
238 * if the number of rows specified by a constructor or by
239 * the <tt>setRows</tt> method is non-zero. In that case, the number
240 * of columns displayed in the layout is determined by the total
241 * number of components and the number of rows specified.
242 * @param cols the number of columns in this layout
243 * @exception IllegalArgumentException if the value of both
244 * <code>rows</code> and <code>cols</code> is set to zero
245 * @since 1.1
246 */
247 public void setColumns(int cols) {
248 if ((cols == 0) && (this.rows == 0)) {
249 throw new IllegalArgumentException("rows and cols cannot both be zero");
250 }
251 this.cols = cols;
252 }
253
254 /**
255 * Gets the horizontal gap between components.
256 * @return the horizontal gap between components
257 * @since 1.1
258 */
259 public int getHgap() {
260 return hgap;
261 }
262
263 /**
264 * Sets the horizontal gap between components to the specified value.
265 * @param hgap the horizontal gap between components
266 * @since 1.1
267 */
268 public void setHgap(int hgap) {
269 this.hgap = hgap;
270 }
271
272 /**
273 * Gets the vertical gap between components.
274 * @return the vertical gap between components
275 * @since 1.1
276 */
277 public int getVgap() {
278 return vgap;
279 }
280
281 /**
282 * Sets the vertical gap between components to the specified value.
283 * @param vgap the vertical gap between components
284 * @since 1.1
285 */
286 public void setVgap(int vgap) {
287 this.vgap = vgap;
288 }
289
290 /**
291 * Adds the specified component with the specified name to the layout.
292 * @param name the name of the component
293 * @param comp the component to be added
294 */
295 public void addLayoutComponent(String name, Component comp) {
296 }
297
298 /**
299 * Removes the specified component from the layout.
300 * @param comp the component to be removed
301 */
302 public void removeLayoutComponent(Component comp) {
303 }
304
|