CS361
Project
1
Learning
to use Swing
due: Wednesday,
February 13, before I leave for the day
Assignment
Create
a Swing window that displays a table with 4 rows, each row displaying the 13 cards of one suit and showing one empty spot. The empty spot should be on the left and the cards should be displayed in order from ace (on the left) up to king (on the right) as shown below:
Details
- I am providing you with a zip file that contains the pictures of the cards for you to use.
- The empty spot on the left side of each row should be displayed using the "gray.gif" file.
- You should write a Main class with a method with header "public
static void main(String[] args)" that starts things going. To run
your program, the user just needs to execute that method. The main method should just create and display a JFrame (window) displaying the cards.
- The background should be a pale green as shown above.
- If your window is covered by another window and then uncovered again, the cards should reappear in the uncovered portion of the window.
- All your methods need to
have Javadoc style headers. If you are unfamiliar with Javadoc, take a look at http://java.sun.com/j2se/javadoc/writingdoccomments/
Hints
- I am providing you with the following simple program Main.java to show you how to create a Swing window and display an image in it. However, one of the purposes of this project is to get you
started practicing using libraries and learning how to read, use, and modify existing
code. Therefore, I will not be giving you much more written guidance in how
to do what I want you to do in this project and you are expected to read the documentation
and experiment with library code and code I give you to figure out how to do it.
However, as mentioned in the course syllabus, I will be happy to help you if you
come to me with questions after trying unsuccessfully to do it yourself first.
- To learn how to create the window I want,
I recommend that you read the Java SwingTutorial. Note that you can download this tutorial to your own machine
and so access the tutorial even when you are off line. There are also books with
material on Swing in the Science library and in the Mudd lab.
Please do not take the books out of the labs or check the books out of the library.
- A good place to look to find out what Swing classes (and other Java
library classes) can do is the online Java
1.5 API. You are welcome to use Java 1.6 if you prefer. This API documentation
can also be downloaded to your machine so that you can access it off line.
- You are welcome to
create any additional classes and methods you wish.
- This
project might seem hard at first glance if you've never used the Swing package, but I have already given you the compilicated part in the sample program. This project mainly consists of simple extensions of that program.
Extra Credit
- For one point extra credit, add the following feature: When
the close box (in the upper right or left corner of the JFrame) is clicked, the application
quits just like when the Quit or Exit menu item is chosen in a real application.
- Note: For extra credit work in this and all future projects, you will receive no extra credit if the feature is only partially implemented. Furthermore, a fully-working feature is worth only a point or two. However, you can receive more extra credit points than a point or two if your solution is particularly elegant.
What to hand in
Hand in a hard copy
of all the source code files you created or modified and also zip up all source
code files and send the zip file to me
as an email attachment. See the course
web page on handing in assignments for further details.
For
fun: An Ambiguous Recommendation
"I am pleased to say that Andrew
is a former student of mine."