Tutorial Index
AWT Fundamentals
Exercises
By

About This Short Course
Short Course
Exercises
Exercise Outline
Welcome to the jGuru exercises for the AWT Fundamentals short course.
These exercises show how to use the Abstract Window Toolkit
components to interact with forms and windows.
These exercises demonstrate how to use the Abstract Window Toolkit (AWT) components and events within your
Java technology applications. The exercises include stand-alone programs as well as applets that let you learn
how to create and interact with AWT components within your programs.
When you finish these exercises, you will know the basic steps for
designing and developing AWT-based Java programs for client-side computing.
About Exercises
A jGuru exercise is a flexible exercise that provides varying levels
of help according to the student's needs. Some students may complete the
exercise using only the information and the task list in the exercise
body; some may want a few hints (Help); while others may want a step-by-step
guide to successful completion (Solution). Since complete solutions
are provided in addition to help, students can skip an exercise and still be
able to complete later exercises that required the skipped
one(s).
The Anatomy of an Exercise
Each exercise includes a list of any prerequisite exercises, a list
of skeleton code for you to start with, links to necessary API pages,
and a text description of the exercise's educational goal. In addition,
buttons link you to the following information:
-
Help: Gives you help or hints on the
current exercise, an annotated solution. For ease of use,
the task information is duplicated on the help page with the
actual help information indented beneath it.
-
Solution: The
<applet>
tag and Java source resulting in the expected behavior.
-
API Documentation: A link directly to
any necessary online API documentation.
Exercise Design Goals
There are three fundamental exercise types that you may encounter:
- "Blank
screen"
- You are confronted
with a "blank screen" and
you
create the entire desired functionality yourself.
-
Extension
- You extend the functionality of an existing, correctly-working program.
- Repair
- You repair undesirable behavior in an existing program.
To make learning easier, exercises, where possible, address only
the specific technique being taught in that exercise. Irrelevant,
unrelated, and overly complex materials are avoided.
Where possible, exercises execute on the Web. However, exercises
that must access Java features or library elements that could cause
security violations are not executed on the web.
Exercises
-
Component Madness
Create a simple GUI by adding components to an applet.
Educational goal(s):
- Learn how to construct components.
- Learn how to add components to an applet.
-
Selecting Students and Courses
Create a simple applet to allow users to select a student and a course from a
List and a
Choice component.
Educational goal(s):
- Learn how to create components with multiple choices.
-
Beeping Mouse
Create an applet that beeps each time the user clicks a mouse button.
Educational goal(s):
- Understand the source-target event model.
- Learn how to listen for mouse button events.
-
Counting Mouse Clicks
Create an applet that counts and displays the number of times a button has
been pressed.
Educational goal(s):
- Understand the source-target event model.
- Learn how to process command button actions.
-
Counting Key Presses
Create an applet that counts and displays the total number of key presses.
Educational goal(s):
- Understand the source-target event model.
- Learn how to process key events.
-
Using the List Component
Create an applet that displays items in a list and responds to item
selections.
Educational goal(s):
- Understand the source-target event model.
- Understand how to process item events.
-
Phonebook Searching
Create a phonebook look-up applet that displays the phone number for the
person selected and looks up the name for an entered phone number.
Educational goal(s):
- Understand the source-target event model.
- Learn how to listen for action events for
buttons and text fields.
- Learn how to listen for pull-down list
changes.
- Learn how to listen for keystrokes to
restrict input.
- Learn how to use event adapters as well as event listeners.
-
Radio Buttons
Create an applet with two radio buttons that allow
the user to choose between two opinions of the Java programming language.
Educational goal(s):
- Learn how to use the
Checkbox widget.
- Learn about grouping them into a
CheckboxGroup.
- Understand how to process item events.
-
Displaying Files
This exercise produces an application rather than an applet. This application
demonstrates GUI design within the primary application window.
Educational goal(s):
- Learn how to work with a
Frame.
- Learn how to use a
List.
-
Converting an Applet to an Application
Create an applet so that it appears within a Frame
rather than in a browser.
Educational goal(s):
- To understand how to convert an applet into an application.
-
OK Dialog
Create and open a dialog box that waits for the user to hit the
"OK" button before it disappears and the applet finishes. Have the
applet add the label "Back from dialog..." to its display when the
dialog box has returned. Hide and dispose of the dialog box right before adding
the label.
Educational goal(s):
- Learn how to work with a
Dialog.
- Learn how to deal with modal dialogs.
-
Display a File from FileDialog
Create an application that instantiates and shows a FileDialog
instance. Use getFile() to obtain the selected filename and display
it as a label on the screen.
Educational goal(s):
-
Menus
Given an application (or applet) that constructs a Frame
instance set up with a "File" menu, create a "Help" menu
that uses MenuItem objects.
Educational goal(s):
- Learn how to work with menus.
Copyright 1996-2000 jGuru.com. All Rights Reserved.
|