|
Training Index
by
Help
API Docs
About This Short Course
Short Course
Exercises
In this exercise, you will construct a number of components and add them to
an applet. No events are handled nor is the layout considered. You may
experiment with the effect on the layout of changing the applet size by using appletviewer
to test your applet and resizing the window.
In the applet, when you add components, they will be managed by the default
layout manager of Applet, which is FlowLayout.
Skeleton Code
Tasks
1. Add a new Label
to the applet with text of "Some
Components".
2. Add a new Button with a label of "OK"
to the applet.
3. Add another Button with a label of "A Big Button" to the applet.
4. Add a new Checkbox with a label of "Anybody home?" to the applet.
5. Add a new TextField that is 20 characters wide to the applet.
Note: The number of columns that you pass represents the preferred
number of characters to be visible. This means:
- Some layout managers may ignore this
setting.
- Because the preferred size is based on the
size of the letter
"M", if the TextField uses a proportional font, you may actually
see more than 20 characters when displayed in a layout manager that
respects the preferred width of the
TextField.
6. Add a new TextArea that is 4 rows by 10 character columns to the applet. Again, these sizes represent the preferred size of the TextArea, which may be respected or ignored by the layout manager in use.
Where help exists, the task numbers above are linked to the
step-by-step help page.
Solution Source
Demonstration
When you run your applet, it should look like the following.
Copyright 1996-2000 jGuru.com. All Rights Reserved.
|