Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 

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:

    1. Some layout managers may ignore this setting.
    2. 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.

Next Exercise

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.


Print Button
[ This page was updated: 21-Sep-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary | Feedback | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.