Create the layout
- From the 'Layouts' page on the Object Palette, choose 'Border' and click once in the Empty Space in the Working Model.
- Select LeftSide from the 'Extended Layouts' page, and click once in the North of the Border Layout. A leftside layout will appear in the 'North' section.
- Select Flow from the 'Layouts' page, and click once in the empty space of the leftside layout.
- From the 'Swing' page, choose 'Button' (JButton). Click four times in the Flow layout to place four JButtons into it.
- Select Matrix from the 'Extended Layouts' page, and click once in the empty space in the leftside layout.
A Matrix Layout is very useful for creating standard forms with textfields and labels. It allows you to place components in a grid with each column or row taking the smallest 'preferred' size.
Before adding items to the Matrix, we will edit its properties.
- The properties for the Matrix should be displayed in the Composer.
- Change the vertical gap to 0.
- Change the number of columns to 4.
Now we will add items to the Matrix.
- From the 'Swing' page, choose 'Label' (JLabel).
- Click once in each of the upper four spaces of the Matrix to place a JLabel in each space.
- From the 'Swing' page, choose 'TextField' (JTextField).
- Click once in each of the lower four spaces of the Matrix to place a JTextField in each space.
- Choose "Hide all empty panels" from the parts menu. This will hide the empty spaces in the layouts.
We will now set up some of the properties for the parts which we have just added.
- Click once on the first button.
- Change the Object name of the button to "connect".
- Change the JButton text of the button to "Connect".
- Click once on the second button.
- Change the Object name of the button to "showAvailable".
- Change the JButton text of the button to "Show available items".
- Click once on the third button.
- Change the Object name of the button to "previous".
- Change the JButton text of the button to "Previous".
- Click once on the fourth button.
- Change the Object name of the button to "next".
- Change the JButton text of the button to "Next".
Next we will change the labels in the Matrix display.
- Click once on the first label (in the upper left-hand corner of the Matrix).
- Change the JLabel text of the label to "Product number".
- Click once on the second label.
- Change its JLabel text to "Description".
- Click once on the third label.
- Change its JLabel text to "Quantity on hand".
- Click once on the fourth label.
- Change its JLabel text to "Purchase cost".
Now we will change the names of the TextFields in the Matrix.
- Click once on the first TextField (in the bottom left-hand corner of the Matrix).
- Change the Object name of the TextField to "productNumber".
- Click once on the second TextField.
- Change its Object name to "description".
- Set the number of columns to 20. This will give more room to dispay the descriptions.
- Click once on the third TextField.
- Change its Object name to "quantityOnHand".
- Click once on the fourth TextField.
- Change its Object name to "purchaseCost".
You have now set up the user interface for the first stage of your database program. To check that the names are correct, take a moment to confirm that your buttons read, from left to right, "Connect", "Show available items", "Previous" and "Next". Your labels should read, from left to right, "Product Number", "Description", "Quantity on Hand", and "Purchase Cost". Your TextFields should have Object names of "productNumber", "description", "quantityOnHand", and "purchaseCost".
| Data Representations, Inc. http://www.datarepresentations.com support@datarepresentations.com sales@datarepresentations.com |