![]() |
![]() |
When the Visual Composition Editor opens for the new ToDoList applet, the default JApplet is represented as a gray rectangle on the free-form surface. To build the rest of the user interface, you must add several other visual beans. When you have finished creating the user interface for the To-Do List applet, the free-form surface of the Visual Composition Editor should look like this:
To make a user interface that looks like this, you need to add, size, and align the remaining beans.
Note:
As you add beans to the applet, you may find that the default JApplet bean is too small to
accommodate all the other beans. If this happens, you can resize the JApplet bean by
selecting it and dragging one of the selection handles using mouse button
Although this bean uses a <null> layout manager, it could be built using one of the layout managers, such as GridBagLayout. For an example of creating the user interface for this bean in GridBagLayout, see "Creating a GUI Using GridBagLayout" in the online helps.
In this stage of the applet creation, you add a JTextField bean that is used to enter the To-Do items, and a JLabel bean to identify the field. These beans are in the Swing category of the beans palette.
Tip: As you work with the palette, you may find the icons too small for your preference. To make them larger, right-click on any gray area on the palette and select Show Large Icons from the pop-up pane.
If you
accidentally picked the wrong bean and have not dropped the bean into the JApplet yet,
select the correct bean, or select the Selection tool from the beans palette
to unload the mouse pointer.
After you have added the JTextField bean to the JApplet, you can move it to a new location by dragging it with the mouse. You can also resize it by dragging a side of the rectangle.
Don't worry about their exact positions. Later you'll learn how to use the tools from the tool bar to match sizes and align beans.
Change the text of JLabel to To-Do Item by editing the text as follows:
Tip: You can also copy a bean using the Ctrl key. Position the mouse pointer over the JLabel bean, hold down the Ctrl key, and drag the copy of the bean to below the JTextField bean.
Add a scroll pane so that your list of items can be scrolled.
To create the list in which the To-Do items are displayed, you need to add a JList:
To add and remove items from the To-Do list, you need to add two buttons:
Notice that the mouse pointer remains a crosshair, indicating that it is still loaded with the JButton bean. To add another JButton, click mouse button 1 below JButton1.
Congratulations! You have just created your first user interface using VisualAge for Java. Next, you need to size and align the beans within the To-Do List applet.
![]() |
![]() |