Exercise 2: Starting the Layout
When you start a new layout, a 4-by-3 grid appears in the layout window. This grid represents your application. You add components to the application by clicking on a component in the palette and then clicking in the desired cell. Before adding a component, however, you must set up the grid to meet the needs of your application. In this exercise you will learn how to add cells to the grid and how to set its basic characteristics, such as color, border relief, and border width.
Adding Cells to the Grid
- Click the cell the in upper-left corner of the layout window.
A grid is displayed across the first row and first column.
- On the keyboard, press the down arrow key four times.
Java WorkShop adds four rows of cells to the grid. You now have a 4-by-7 grid in which you can place GUI components.
- Enlarge the layout window by placing the pointer on the window border or corner and dragging.
Make the window large enough so you can see the entire grid.
Setting Attributes
- Select the container area of the layout window by clicking on the blue background between the grid and the outside of the window.
The title of the layout window should be "Panel". If your layout window's title bar says "Frame", choose GUI -> Set Window Type; then click the Panel radio button and click OK.
- Click the attribute editor
button on the Java WorkShop main toolbar.
The Edit Attributes window is displayed. In the attribute editor, you can change the attributes of the panel, including the background color, border relief, and border width.
- In the attribute editor, type lightsteelblue in the background box.
To select a different color, click the ellipsis button to the right of the background box. A color chooser opens where you can move the color sliders and select a color; then click OK.
- In the borderRelief box, select raised from the list box.
- Type 3 in the borderWidth box.
- Click OK.
The container color changes to light steel blue. The grid border is raised and becomes three pixels wide. The attribute editor closes.
- Choose GUI -> Save Generate.
Next lesson:
- Exercise 3: Adding Components