KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > layout > FormatLayout


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * -----------------
28  * FormatLayout.java
29  * -----------------
30  * (C) Copyright 2000-2005, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: FormatLayout.java,v 1.4 2005/10/18 13:16:50 mungady Exp $
36  *
37  * Changes (from 26-Oct-2001)
38  * --------------------------
39  * 26-Oct-2001 : Changed package to com.jrefinery.layout.* (DG);
40  * 26-Jun-2002 : Removed redundant code (DG);
41  * 10-Oct-2002 : Fixed errors reported by Checkstyle (DG);
42  *
43  */

44
45 package org.jfree.layout;
46
47 import java.awt.Component JavaDoc;
48 import java.awt.Container JavaDoc;
49 import java.awt.Dimension JavaDoc;
50 import java.awt.Insets JavaDoc;
51 import java.awt.LayoutManager JavaDoc;
52 import java.io.Serializable JavaDoc;
53
54 /**
55  * A layout manager that spaces components over six columns in seven different
56  * formats.
57  *
58  * @author David Gilbert
59  */

60 public class FormatLayout implements LayoutManager JavaDoc, Serializable JavaDoc {
61
62     /** For serialization. */
63     private static final long serialVersionUID = 2866692886323930722L;
64     
65     /** A useful constant representing layout format 1. */
66     public static final int C = 1;
67
68     /** A useful constant representing layout format 2. */
69     public static final int LC = 2;
70
71     /** A useful constant representing layout format 3. */
72     public static final int LCB = 3;
73
74     /** A useful constant representing layout format 4. */
75     public static final int LCLC = 4;
76
77     /** A useful constant representing layout format 5. */
78     public static final int LCLCB = 5;
79
80     /** A useful constant representing layout format 6. */
81     public static final int LCBLC = 6;
82
83     /** A useful constant representing layout format 7. */
84     public static final int LCBLCB = 7;
85
86     /** The layout format for each row. */
87     private int[] rowFormats;
88
89     /** The gap between the rows. */
90     private int rowGap;
91
92     /**
93      * The gaps between the columns (gap[0] is the gap following column zero).
94      */

95     private int[] columnGaps;
96
97     /** Working array for recording the height of each row. */
98     private int[] rowHeights;
99
100     /** The total height of the layout. */
101     private int totalHeight;
102
103     /** Working array for recording the width of each column. */
104     private int[] columnWidths;
105
106     /** The total width of the layout. */
107     private int totalWidth;
108
109     /** Combined width of columns 1 and 2. */
110     private int columns1and2Width;
111
112     /** Combined width of columns 4 and 5. */
113     private int columns4and5Width;
114
115     /** Combined width of columns 1 to 4. */
116     private int columns1to4Width;
117
118     /** Combined width of columns 1 to 5. */
119     private int columns1to5Width;
120
121     /** Combined width of columns 0 to 5. */
122     private int columns0to5Width;
123
124     /**
125      * Constructs a new layout manager that can be used to create input forms.
126      * The layout manager works by arranging components in rows using six
127      * columns (some components will use more than one column).
128      * <P>
129      * Any component can be added, but I think of them in terms of Labels,
130      * Components, and Buttons.
131      * The formats available are: C, LC, LCB, LCLC, LCLCB, LCBLC or LCBLCB.
132      * <table>
133      * <tr>
134      * <td>C</td>
135      * <td>1 component in this row (spread across all six columns).</td>
136      * </tr>
137      * <tr>
138      * <td>LC</td>
139      * <td>2 components, a label in the 1st column, and a component using the
140      * remaining 5 columns).</td>
141      * </tr>
142      * <tr>
143      * <td>LCB</td>
144      * <td>3 components, a label in the 1st column, a component spread across
145      * the next 4, and a button in the last column.</td>
146      * </tr>
147      * <tr>
148      * <td>LCLC</td>
149      * <td>4 components, a label in column 1, a component in 2-3, a label in
150      * 4 and a component in 5-6.</td>
151      * </tr>
152      * <tr>
153      * <td>LCLCB</td>
154      * <td>5 components, a label in column 1, a component in 2-3, a label
155      * in 4, a component in 5 and a button in 6.</td>
156      * </tr>
157      * <tr>
158      * <td>LCBLC</td>
159      * <td>5 components, a label in column 1, a component in 2, a button in 3,
160      * a label in 4, a component in 5-6.</td>
161      * </tr>
162      * <tr>
163      * <td>LCBLCB</td>
164      * <td>6 components, one in each column.</td>
165      * </tr>
166      * </table>
167      * <P>
168      * Columns 1 and 4 expand to accommodate the widest label, and 3 and 6 to
169      * accommodate the widest button.
170      * <P>
171      * Each row will contain the number of components indicated by the format.
172      * Be sure to specify enough row formats to cover all the components you
173      * add to the layout.
174      *
175      * @param rowCount the number of rows.
176      * @param rowFormats the row formats.
177      */

178     public FormatLayout(final int rowCount, final int[] rowFormats) {
179
180         this.rowFormats = rowFormats;
181         this.rowGap = 2;
182         this.columnGaps = new int[5];
183         this.columnGaps[0] = 10;
184         this.columnGaps[1] = 5;
185         this.columnGaps[2] = 5;
186         this.columnGaps[3] = 10;
187         this.columnGaps[4] = 5;
188
189         // working structures...
190
this.rowHeights = new int[rowCount];
191         this.columnWidths = new int[6];
192     }
193
194     /**
195      * Returns the preferred size of the component using this layout manager.
196      *
197      * @param parent the parent.
198      *
199      * @return the preferred size of the component.
200      */

201     public Dimension JavaDoc preferredLayoutSize(final Container JavaDoc parent) {
202
203         Component JavaDoc c0, c1, c2, c3, c4, c5;
204
205         synchronized (parent.getTreeLock()) {
206             final Insets JavaDoc insets = parent.getInsets();
207             int componentIndex = 0;
208             final int rowCount = this.rowHeights.length;
209             for (int i = 0; i < this.columnWidths.length; i++) {
210                 this.columnWidths[i] = 0;
211             }
212             this.columns1and2Width = 0;
213             this.columns4and5Width = 0;
214             this.columns1to4Width = 0;
215             this.columns1to5Width = 0;
216             this.columns0to5Width = 0;
217
218             this.totalHeight = 0;
219             for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
220             final int format
221                 = this.rowFormats[rowIndex % this.rowFormats.length];
222                 switch (format) {
223                     case FormatLayout.C:
224                         c0 = parent.getComponent(componentIndex);
225                         updateC(rowIndex, c0.getPreferredSize());
226                         componentIndex = componentIndex + 1;
227                         break;
228                     case FormatLayout.LC:
229                         c0 = parent.getComponent(componentIndex);
230                         c1 = parent.getComponent(componentIndex + 1);
231                         updateLC(rowIndex, c0.getPreferredSize(),
232                                 c1.getPreferredSize());
233                         componentIndex = componentIndex + 2;
234                         break;
235                     case FormatLayout.LCB:
236                         c0 = parent.getComponent(componentIndex);
237                         c1 = parent.getComponent(componentIndex + 1);
238                         c2 = parent.getComponent(componentIndex + 2);
239                         updateLCB(rowIndex,
240                                   c0.getPreferredSize(),
241                                   c1.getPreferredSize(),
242                                   c2.getPreferredSize());
243                         componentIndex = componentIndex + 3;
244                         break;
245                     case FormatLayout.LCLC:
246                         c0 = parent.getComponent(componentIndex);
247                         c1 = parent.getComponent(componentIndex + 1);
248                         c2 = parent.getComponent(componentIndex + 2);
249                         c3 = parent.getComponent(componentIndex + 3);
250                         updateLCLC(rowIndex,
251                                    c0.getPreferredSize(),
252                                    c1.getPreferredSize(),
253                                    c2.getPreferredSize(),
254                                    c3.getPreferredSize());
255                         componentIndex = componentIndex + 4;
256                         break;
257                     case FormatLayout.LCBLC:
258                         c0 = parent.getComponent(componentIndex);
259                         c1 = parent.getComponent(componentIndex + 1);
260                         c2 = parent.getComponent(componentIndex + 2);
261                         c3 = parent.getComponent(componentIndex + 3);
262                         c4 = parent.getComponent(componentIndex + 4);
263                         updateLCBLC(rowIndex,
264                                     c0.getPreferredSize(),
265                                     c1.getPreferredSize(),
266                                     c2.getPreferredSize(),
267                                     c3.getPreferredSize(),
268                                     c4.getPreferredSize());
269                         componentIndex = componentIndex + 5;
270                         break;
271                     case FormatLayout.LCLCB:
272                         c0 = parent.getComponent(componentIndex);
273                         c1 = parent.getComponent(componentIndex + 1);
274                         c2 = parent.getComponent(componentIndex + 2);
275                         c3 = parent.getComponent(componentIndex + 3);
276                         c4 = parent.getComponent(componentIndex + 4);
277                         updateLCLCB(rowIndex,
278                                     c0.getPreferredSize(),
279                                     c1.getPreferredSize(),
280                                     c2.getPreferredSize(),
281                                     c3.getPreferredSize(),
282                                     c4.getPreferredSize());
283                         componentIndex = componentIndex + 5;
284                         break;
285                     case FormatLayout.LCBLCB:
286                         c0 = parent.getComponent(componentIndex);
287                         c1 = parent.getComponent(componentIndex + 1);
288                         c2 = parent.getComponent(componentIndex + 2);
289                         c3 = parent.getComponent(componentIndex + 3);
290                         c4 = parent.getComponent(componentIndex + 4);
291                         c5 = parent.getComponent(componentIndex + 5);
292                         updateLCBLCB(rowIndex,
293                                      c0.getPreferredSize(),
294                                      c1.getPreferredSize(),
295                                      c2.getPreferredSize(),
296                                      c3.getPreferredSize(),
297                                      c4.getPreferredSize(),
298                                      c5.getPreferredSize());
299                         componentIndex = componentIndex + 6;
300                         break;
301                 }
302             }
303             complete();
304             return new Dimension JavaDoc(this.totalWidth + insets.left + insets.right,
305                     this.totalHeight + (rowCount - 1) * this.rowGap
306                                  + insets.top + insets.bottom);
307         }
308     }
309
310     /**
311      * Returns the minimum size of the component using this layout manager.
312      *
313      * @param parent the parent.
314      *
315      * @return the minimum size of the component
316      */

317     public Dimension JavaDoc minimumLayoutSize(final Container JavaDoc parent) {
318
319         Component JavaDoc c0, c1, c2, c3, c4, c5;
320
321         synchronized (parent.getTreeLock()) {
322             final Insets JavaDoc insets = parent.getInsets();
323             int componentIndex = 0;
324             final int rowCount = this.rowHeights.length;
325             for (int i = 0; i < this.columnWidths.length; i++) {
326                 this.columnWidths[i] = 0;
327             }
328             this.columns1and2Width = 0;
329             this.columns4and5Width = 0;
330             this.columns1to4Width = 0;
331             this.columns1to5Width = 0;
332             this.columns0to5Width = 0;
333             final int totalHeight = 0;
334             for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
335
336                 final int format
337                     = this.rowFormats[rowIndex % this.rowFormats.length];
338
339                 switch (format) {
340                     case FormatLayout.C:
341                         c0 = parent.getComponent(componentIndex);
342                         this.columns0to5Width = Math.max(
343                             this.columns0to5Width, c0.getMinimumSize().width
344                         );
345                         componentIndex = componentIndex + 1;
346                         break;
347                     case FormatLayout.LC:
348                         c0 = parent.getComponent(componentIndex);
349                         c1 = parent.getComponent(componentIndex + 1);
350                         updateLC(rowIndex,
351                                  c0.getMinimumSize(),
352                                  c1.getMinimumSize());
353                         componentIndex = componentIndex + 2;
354                         break;
355                     case FormatLayout.LCB:
356                         c0 = parent.getComponent(componentIndex);
357                         c1 = parent.getComponent(componentIndex + 1);
358                         c2 = parent.getComponent(componentIndex + 2);
359                         updateLCB(rowIndex,
360                                   c0.getMinimumSize(),
361                                   c1.getMinimumSize(),
362                                   c2.getMinimumSize());
363                         componentIndex = componentIndex + 3;
364                         break;
365                     case FormatLayout.LCLC:
366                         c0 = parent.getComponent(componentIndex);
367                         c1 = parent.getComponent(componentIndex + 1);
368                         c2 = parent.getComponent(componentIndex + 2);
369                         c3 = parent.getComponent(componentIndex + 3);
370                         updateLCLC(rowIndex,
371                                    c0.getMinimumSize(),
372                                    c1.getMinimumSize(),
373                                    c2.getMinimumSize(),
374                                    c3.getMinimumSize());
375                         componentIndex = componentIndex + 3;
376                         break;
377                     case FormatLayout.LCBLC:
378                         c0 = parent.getComponent(componentIndex);
379                         c1 = parent.getComponent(componentIndex + 1);
380                         c2 = parent.getComponent(componentIndex + 2);
381                         c3 = parent.getComponent(componentIndex + 3);
382                         c4 = parent.getComponent(componentIndex + 4);
383                         updateLCBLC(rowIndex,
384                                     c0.getMinimumSize(),
385                                     c1.getMinimumSize(),
386                                     c2.getMinimumSize(),
387                                     c3.getMinimumSize(),
388                                     c4.getMinimumSize());
389                         componentIndex = componentIndex + 4;
390                         break;
391                     case FormatLayout.LCLCB:
392                         c0 = parent.getComponent(componentIndex);
393                         c1 = parent.getComponent(componentIndex + 1);
394                         c2 = parent.getComponent(componentIndex + 2);
395                         c3 = parent.getComponent(componentIndex + 3);
396                         c4 = parent.getComponent(componentIndex + 4);
397                         updateLCLCB(rowIndex,
398                                     c0.getMinimumSize(),
399                                     c1.getMinimumSize(),
400                                     c2.getMinimumSize(),
401                                     c3.getMinimumSize(),
402                                     c4.getMinimumSize());
403                         componentIndex = componentIndex + 4;
404                         break;
405                     case FormatLayout.LCBLCB:
406                         c0 = parent.getComponent(componentIndex);
407                         c1 = parent.getComponent(componentIndex + 1);
408                         c2 = parent.getComponent(componentIndex + 2);
409                         c3 = parent.getComponent(componentIndex + 3);
410                         c4 = parent.getComponent(componentIndex + 4);
411                         c5 = parent.getComponent(componentIndex + 5);
412                         updateLCBLCB(rowIndex,
413                                      c0.getMinimumSize(),
414                                      c1.getMinimumSize(),
415                                      c2.getMinimumSize(),
416                                      c3.getMinimumSize(),
417                                      c4.getMinimumSize(),
418                                      c5.getMinimumSize());
419                         componentIndex = componentIndex + 5;
420                         break;
421                 }
422             }
423             complete();
424             return new Dimension JavaDoc(this.totalWidth + insets.left + insets.right,
425                                  totalHeight + (rowCount - 1) * this.rowGap
426                                  + insets.top + insets.bottom);
427         }
428     }
429
430     /**
431      * Performs the layout of the container.
432      *
433      * @param parent the parent.
434      */

435     public void layoutContainer(final Container JavaDoc parent) {
436         Component JavaDoc c0, c1, c2, c3, c4, c5;
437
438         synchronized (parent.getTreeLock()) {
439             final Insets JavaDoc insets = parent.getInsets();
440             int componentIndex = 0;
441             final int rowCount = this.rowHeights.length;
442             for (int i = 0; i < this.columnWidths.length; i++) {
443                 this.columnWidths[i] = 0;
444             }
445             this.columns1and2Width = 0;
446             this.columns4and5Width = 0;
447             this.columns1to4Width = 0;
448             this.columns1to5Width = 0;
449             this.columns0to5Width
450                 = parent.getBounds().width - insets.left - insets.right;
451
452             this.totalHeight = 0;
453             for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
454                 final int format
455                     = this.rowFormats[rowIndex % this.rowFormats.length];
456                 switch (format) {
457                     case FormatLayout.C:
458                         c0 = parent.getComponent(componentIndex);
459                         updateC(rowIndex, c0.getPreferredSize());
460                         componentIndex = componentIndex + 1;
461                         break;
462                     case FormatLayout.LC:
463                         c0 = parent.getComponent(componentIndex);
464                         c1 = parent.getComponent(componentIndex + 1);
465                         updateLC(rowIndex, c0.getPreferredSize(),
466                                 c1.getPreferredSize());
467                         componentIndex = componentIndex + 2;
468                         break;
469                     case FormatLayout.LCB:
470                         c0 = parent.getComponent(componentIndex);
471                         c1 = parent.getComponent(componentIndex + 1);
472                         c2 = parent.getComponent(componentIndex + 2);
473                         updateLCB(rowIndex,
474                                   c0.getPreferredSize(),
475                                   c1.getPreferredSize(),
476                                   c2.getPreferredSize());
477                         componentIndex = componentIndex + 3;
478                         break;
479                     case FormatLayout.LCLC:
480                         c0 = parent.getComponent(componentIndex);
481                         c1 = parent.getComponent(componentIndex + 1);
482                         c2 = parent.getComponent(componentIndex + 2);
483                         c3 = parent.getComponent(componentIndex + 3);
484                         updateLCLC(rowIndex,
485                                    c0.getPreferredSize(),
486                                    c1.getPreferredSize(),
487                                    c2.getPreferredSize(),
488                                    c3.getPreferredSize());
489                         componentIndex = componentIndex + 4;
490                         break;
491                     case FormatLayout.LCBLC:
492                         c0 = parent.getComponent(componentIndex);
493                         c1 = parent.getComponent(componentIndex + 1);
494                         c2 = parent.getComponent(componentIndex + 2);
495                         c3 = parent.getComponent(componentIndex + 3);
496                         c4 = parent.getComponent(componentIndex + 4);
497                         updateLCBLC(rowIndex,
498                                     c0.getPreferredSize(),
499                                     c1.getPreferredSize(),
500                                     c2.getPreferredSize(),
501                                     c3.getPreferredSize(),
502                                     c4.getPreferredSize());
503                         componentIndex = componentIndex + 5;
504                         break;
505                     case FormatLayout.LCLCB:
506                         c0 = parent.getComponent(componentIndex);
507                         c1 = parent.getComponent(componentIndex + 1);
508                         c2 = parent.getComponent(componentIndex + 2);
509                         c3 = parent.getComponent(componentIndex + 3);
510                         c4 = parent.getComponent(componentIndex + 4);
511                         updateLCLCB(rowIndex,
512                                     c0.getPreferredSize(),
513                                     c1.getPreferredSize(),
514                                     c2.getPreferredSize(),
515                                     c3.getPreferredSize(),
516                                     c4.getPreferredSize());
517                         componentIndex = componentIndex + 5;
518                         break;
519                     case FormatLayout.LCBLCB:
520                         c0 = parent.getComponent(componentIndex);
521                         c1 = parent.getComponent(componentIndex + 1);
522                         c2 = parent.getComponent(componentIndex + 2);
523                         c3 = parent.getComponent(componentIndex + 3);
524                         c4 = parent.getComponent(componentIndex + 4);
525                         c5 = parent.getComponent(componentIndex + 5);
526                         updateLCBLCB(rowIndex,
527                                      c0.getPreferredSize(),
528                                      c1.getPreferredSize(),
529                                      c2.getPreferredSize(),
530                                      c3.getPreferredSize(),
531                                      c4.getPreferredSize(),
532                                      c5.getPreferredSize());
533                         componentIndex = componentIndex + 6;
534                         break;
535                 }
536             }
537             complete();
538
539             componentIndex = 0;
540             int rowY = insets.top;
541             final int[] rowX = new int[6];
542             rowX[0] = insets.left;
543             rowX[1] = rowX[0] + this.columnWidths[0] + this.columnGaps[0];
544             rowX[2] = rowX[1] + this.columnWidths[1] + this.columnGaps[1];
545             rowX[3] = rowX[2] + this.columnWidths[2] + this.columnGaps[2];
546             rowX[4] = rowX[3] + this.columnWidths[3] + this.columnGaps[3];
547             rowX[5] = rowX[4] + this.columnWidths[4] + this.columnGaps[4];
548             final int w1to2 = this.columnWidths[1] + this.columnGaps[1]
549                               + this.columnWidths[2];
550             final int w4to5 = this.columnWidths[4] + this.columnGaps[4]
551                               + this.columnWidths[5];
552             final int w1to4 = w1to2 + this.columnGaps[2] + this.columnWidths[3]
553                         + this.columnGaps[3] + this.columnWidths[4];
554             final int w1to5 = w1to4 + this.columnGaps[4] + this.columnWidths[5];
555             final int w0to5 = w1to5 + this.columnWidths[0] + this.columnGaps[0];
556             for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
557                 final int format
558                     = this.rowFormats[rowIndex % this.rowFormats.length];
559
560                 switch (format) {
561                 case FormatLayout.C:
562                     c0 = parent.getComponent(componentIndex);
563                     c0.setBounds(rowX[0], rowY, w0to5,
564                             c0.getPreferredSize().height);
565                     componentIndex = componentIndex + 1;
566                     break;
567                 case FormatLayout.LC:
568                     c0 = parent.getComponent(componentIndex);
569                     c0.setBounds(
570                         rowX[0],
571                         rowY + (this.rowHeights[rowIndex]
572                                      - c0.getPreferredSize().height) / 2,
573                         this.columnWidths[0], c0.getPreferredSize().height
574                     );
575                     c1 = parent.getComponent(componentIndex + 1);
576                     c1.setBounds(
577                         rowX[1],
578                         rowY + (this.rowHeights[rowIndex]
579                                      - c1.getPreferredSize().height) / 2,
580                         w1to5, c1.getPreferredSize().height
581                     );
582                     componentIndex = componentIndex + 2;
583                     break;
584                 case FormatLayout.LCB:
585                     c0 = parent.getComponent(componentIndex);
586                     c0.setBounds(
587                         rowX[0],
588                         rowY + (this.rowHeights[rowIndex]
589                                      - c0.getPreferredSize().height) / 2,
590                         this.columnWidths[0], c0.getPreferredSize().height
591                     );
592                     c1 = parent.getComponent(componentIndex + 1);
593                     c1.setBounds(
594                         rowX[1],
595                         rowY + (this.rowHeights[rowIndex]
596                                     - c1.getPreferredSize().height) / 2,
597                         w1to4, c1.getPreferredSize().height
598                     );
599                     c2 = parent.getComponent(componentIndex + 2);
600                     c2.setBounds(
601                         rowX[5],
602                         rowY + (this.rowHeights[rowIndex]
603                                     - c2.getPreferredSize().height) / 2,
604                         this.columnWidths[5], c2.getPreferredSize().height
605                     );
606                     componentIndex = componentIndex + 3;
607                     break;
608                 case FormatLayout.LCLC:
609                     c0 = parent.getComponent(componentIndex);
610                     c0.setBounds(
611                         rowX[0],
612                         rowY + (this.rowHeights[rowIndex]
613                                     - c0.getPreferredSize().height) / 2,
614                         this.columnWidths[0], c0.getPreferredSize().height
615                     );
616                     c1 = parent.getComponent(componentIndex + 1);
617                     c1.setBounds(
618                         rowX[1],
619                         rowY + (this.rowHeights[rowIndex]
620                                     - c1.getPreferredSize().height) / 2,
621                         w1to2, c1.getPreferredSize().height
622                     );
623                     c2 = parent.getComponent(componentIndex + 2);
624                     c2.setBounds(
625                         rowX[3],
626                         rowY + (this.rowHeights[rowIndex]
627                                     - c2.getPreferredSize().height) / 2,
628                         this.columnWidths[3], c2.getPreferredSize().height
629                     );
630                     c3 = parent.getComponent(componentIndex + 3);
631                     c3.setBounds(
632                         rowX[4],
633                         rowY + (this.rowHeights[rowIndex]
634                                     - c3.getPreferredSize().height) / 2,
635                         w4to5, c3.getPreferredSize().height
636                     );