![]() |
![]() |
![]() |
![]() |
Using the GridBag Layout
The GridBag Layout is one of the most versatile and flexible layouts. We will use it to build the entire Transaction Dialog.
- From the Layouts page of the Object Palette, choose GridBag.
- Click once in the Empty Space in the Working Model. A new GridBagLayout appears, initially with one Empty Space available.
- Press the Add Empty button twice (at the top of the GridBag properties page). This will add an additional two Empty Spaces to the layout.
- From the Basic page of the Object Palette, choose Label. Click once in the first Empty Space of the GridBag.
- Change the Label's text to "Enter amount:".
- From the Extended page of the Object Palette, choose ValidText. Click once in the second Empty Space of the GridBag.
- Change its 'Object name' to 'amountField', its 'Type of validation' to 'Float' and its 'Number of columns' to '20'.
- From the Basic page of the Object Palette, choose Button. Click once in the third Empty Space of the GridBag.
- Change its 'Object name' to 'commandButton' and its 'Button text' to 'Command'.
- Choose 'gridbag1' from the partlist (at the top of the Composer window) to view the properties for the GridBag Layout.
The GridBag Layout allows you to give each part a set of constraints which govern how the parts should be positioned. The property sheet for the GridBag Layout contains a table showing all of the constraints for each part. You can edit these directly in the table as well.
The table should have three rows, one for each part that we've added. The column on the left lists the part names. We will now adjust some of these properties.
- For 'label2', change the X and Y both to 0. Change the Top and Left Insets both to 15. Click once on the small square in Fill column to specify a horizontal fill. (The small box changes to a horizontal bar. Clicking four times will cycle through all the states: None, Horizontal, Vertical, and Both.)
- For 'amountField', change the X to 0 and the Y to 1. Change the Left, Bottom and Right Insets each to 15.
- For 'commandButton', change the X to 0 and the Y to 2. Change the Bottom Inset to 15.
You've finished adjusting the constraints for the parts in the Transaction Dialog. The table should look similar to the following:
Data Representations, Inc. http://www.datarepresentations.com support@datarepresentations.com sales@datarepresentations.com |
![]() |
![]() |
![]() |
![]() |