Assignment 1
"Hello World"

Write a Java/Swing application program that creates a window and then creates and displays several pushbutton widgets and several other types of widgets in the window.

Each button should have a different label. When the user presses a button, your program print a message on the standard output (i.e., the terminal window from which you started your program). The message should be different for each of the buttons. In addition, one of the buttons should have a feature where its own label changes each time the button is pushed.

The other widgets should also print a message on standard output when the user interacts with them.


Your program will create the main window (i.e. the window that contains the other widgets), create the widgets and lay them out, create any other data objects you need, and install listeners for your widgets as needed. Then, it lets the Java window system take over, providing the main loop.

Using Objects

Use object-oriented programming to encapsulate the parts of your program separately. In particular, each of your widgets should be a separate object, of a class that you define. It should inherit from the corresponding Swing widget and add the routines and data specific to your widget. That is, anything you need to know about the widget from one callback to another, beyond the information already maintained by Swing (such as the message to be printed for each button).

Java Software

You should use Java and Swing; we are using version 1.8.0 in class demos, version 1.7 is also fine.

If you haven't already, download the Java software from the link on the course home page and run on your own machine. See this page for some additional notes on installation. You can also run Java on the unix machines in the lab, from the unix command line; or the Windows machines in the lab, where Java should should already be installed. If there are any incompatibilities, your code should ultimately compile and run on the machine the TA uses for grading. We will use this first assignment to discover any incompatibilities we didn't know about.

Coding Style

For this assignment focus on writing readable code. In short this means:

Programming Practices

You should follow these general Java programming practices:

And, finally, for uniformity please name your Java class that has your main program in it Main, in file

Coding style will count more as the semester progresses.

How to Submit Your Programs

Follow the procedure here to submit your assignment.

Teaching Assistant

See the course home page for contact info.