CPE 102
Winter
2007
Lab 9
Objectives
Resources
Ground
Rules
Orientation
In this lab you will be creating a simple GUI-based Java
application. This application will consist of an application frame, a
panel, a button, and a text field. When the button is pressed the text field
will be updated with a message and a count reflecting how many times the button
has been pressed. The button label and
message will be provided to the program at run time via the command line
arguments.
Specification
Below are several images of the GUI application you must
develop. Details of the specifications
follow the images. The application must
be provided two strings as command line arguments. You can either start the application from the
command line or modify you IDE to invoke the program with parameters (details
vary by IDE). Because this is a GUI-base
application you will not be able to run it via the SSH terminal window. Here is an example of running it from the
Windows command-window:
Here is what the application looks like when it
starts. Notice that the first string
provided to the program via the command-line, “Push Me!”,
shows up on the JButton. Your program must do this too! The string is quoted because it contains
spaces – if it were not quoted it would be treated as two arguments instead of
one by the shell. The second string has
no spaces so it does not need to be quoted.
Here is what the application looks like after pushing the
button once. Notice that the text in the
JTextField comes partly from the second argument
provided via the command-line when the program was started. The number comes from the program and
represents the number of times the JButton has been
pressed.
Here is what the application looks like after pushing the
button five times:
Here are some important details to keep in mind as you
implement your solution: