|
Tutorial Example
1. Install CookFormLayout TagsTo install CookFormLayout tags to CookSwing, use the Java code below. It only needs to be called once per application. CookFormLayout.setupTagLibrary (CookSwing.getSwingTagLibrary ()) 2. Specify FormLayoutTo use the FormLayout, first place <panel> <formlayout columnspec="pref, 4dlu, 50dlu, 4dlu, min" rowspec="pref, 2dlu, pref, 2dlu, pref" > </formlayout> </panel> FormLayout uses a grid like layout. The beauty of this layout manager, however, lies in the simple yet powerful specifications of how grids are constructed. JGoodies FormLayout can also let developers change a particular row/column spec in the
middle of adding components. However, such feature is not in 3. Add Swing Components with CellConstraintsThen to add a Swing component to this layout, put the component inside a
<cellconstraints value="1, 1"> <label text="Label1"/> </cellconstraints> There are a number of ways of specifying <cellconstraints value="1, 1"> Or, if you prefer, you can be slightly more clear with <cellconstraints xy="1, 1"> Or, if you are serious about being very clear <cellconstraints gridx="1" gridy="1"> Refer to the Note that in FormLayout, the index values of the x/y grid starts from 1, not zero. 4. Row and Column GroupsRow group is useful to set the height of several rows to the same.
<form-rowgroup rows="3, 5, 7"/> 5. Separator
<form-separator text="<formlayout> Tutorial" cellconstraints="1, 1, 5, 1"/> |