|
[Help | Solution | API Docs | Short Course | Magercises] The Java Foundation Classes (JFC) encompass both the Abstract Window Toolkit (AWT) of old and the new Swing components and architecture. The Swing components can be used like AWT components, including 1.1 event handling. In this Magercise, you will setup the environment to compile, then modify, a basic application that displays a label and two buttons. Selecting a button displays a message to the screen. Magercise 2 Prerequisites None. Skeleton Code
FirstAppl.java Tasks
swingall.jar file to your
class path to compile your Swing programs. In the
Installation magercise, you installed
Swing and set the SWINGHOME environment variable to the
installation directory. Now, you need to add the archives to the
CLASSPATH.
Starting with the skeleton code, import the swing package.
To have the components appear one on top of each other, modify the
skeleton's constructor so that it sets the layout to
Create
Create a
Add the Save everything and compile the program. Then run it to see the results. Clicking a button displays a message to the screen. As a precaution, the Save command appends a "1" to the end of the filename you want to save. This can help prevent you from accidently overwriting your source code.
Where help exists, the task numbers above are linked to the step-by-step help page. The following Java source file represents a solution to this Magercise. Copyright © 1998-1999 MageLang Institute. All Rights Reserved. | ||||
|
| ||||||||||||