CS-4811

Java Program #4

JFC/Swing Components

 

Date Assigned:          Tuesday, October 24, 2000

Date Due:                   Tuesday, November 7, 2000

 

Now that we’ve covered the Java Delegation Event Model in detail and have also covered many JFC/Swing components, the objective is to make use of the component library to put a graphical user interface onto the Blackjack program from Lab #1.  To make the job easier, I’ve placed a cards.zip file on the course web page that contains 53 .gif files, one for each card face and one card back image.  Add the card image to the Card class and write separate JFrame and JPanel subclasses to play the game.  Use other JFC components in your user interface to make the game more enjoyable to the player.  For instance, a ‘hit’ and ‘stand’ button would make it easy for the player to make their moves.  As an enhancement, add a wager feature that manages how much a player is betting on the hand.  This can be done with labels or textboxes.  Be creative and see what other GUI widgets you can use to make the game enjoyable to play.

 

As a suggestion, I found it easy to ‘draw’ cards by using the ImageIcon class.  An ImageIcon can be loaded from an image.gif file and can also be used to label a JButton instance.  Using a button to hold the image means that I can use a layout manager to organize the display of the cards on the table (both the dealer’s cards and the player’s cards).  Layout managers are a very useful feature to know about whenever a UI display is being constructed.  Operations, such as resizing the window, are easily handled by the layout manager (who reorganizes the display and repaints the components automatically).

 

As always, once you have a working program to submit, write a report that describes the implementation and discusses how you went about meeting the objectives of the assignment.  Then, email the report (as a .doc, .pdf, or, as a last resort, .txt file) and the Java source files to blessing@msoe.edu.  I will grade your report and email it back to you with my comments and grade for the assignment.