In this lab, you will be writing your first Java class from scratch. You will also be learning about creating graphical programs and the layout of graphical programs. We will still be using the DrJava Interactions Pane to create instances (we'll be moving onto stand-alone programs shortly).
We will concentrate on the following idea that was discussed in class:
There will also be a review of the following two concepts previously covered:
Check out the Lab5 Skeleton from the repository. This skeleton is different than the previous two because it does not contain any Java files or packages.
Your next step is to create a Java package named lab5 in your project.
Finally, you should create a class named App in your lab5 package.
Your skeletal class definition should be in your App.java file. You will fill in the rest of the file so that when you create an instance of a lab5.App at the DrJava Interactions pane, you get a JFrame that looks like this:
You will need to consult information about the components availabe for use in the javax.swing package, and you can do so using the content-assist features of Eclipse, or by using the online Javadocs for the swing package here.
Now create another file and class named App2 and fill in the code appropriately so that when you create a lab5.App2 at the DrJava Interactions Pane, you get a JFrame that looks like this: (note that there are two images here so that you can see what the dropdown from the menu should look like)
Note that these JFrames are not required to have the implied functionality, they must simply appear and look the same as the images shown in this description.
The Lab5.jar
must be submitted using the electronic submission command the evening before (11:59:59pm) your next lab session, the due dates are summarized in the table below.
Recitation Normally Meets on | Recitation for this assignment will meet on | Assignment due on |
Tuesdays | Tuesday, October 7 | Monday, October 13 |
Wednesdays | Wednesday, October 8 | Tuesday, October 14 |
Thursdays | Thursday, October 2 | Wednesday, October 15 |
Fridays | Friday, October 3 | Thursday, October 16 |
If you are going to do some work from home and some work in the lab on this or future lab assignments, you should be aware that to transfer the files from one machine to another, you need to combine some steps that we've already taught you in previous labs. First, when you are done working for the day, you need to export your project and save the resulting JAR file. When ready, you will need to transfer that file to the other machine using a file transfer program. Once the file is on the new machine, you will need to import into an already-existing project (use the Lab 5 skeleton as a base for the project). You will need to do this set of steps each time you want to move the file.
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161