Goal: Display a random fortune from a list of 5 choices with a picture to convey a positive or negative fortune.
BEFORE your program will run, you need to save these pictures into the same folder as your project or .java files. |
Create DriverFortune and PanelFortune using the starter code. Add your code to PanelFortune.
Pseudocode:
How To:
/*1 create a button, attach a listener and add the button to the panel */
(see your Random number program if you need help)
/*2 create a label for the picture and add it to the panel */
picture = new JLabel(); picture.setIcon(new ImageIcon("Smile.gif")); add(picture);
/*3 generate a random number from 0 to 5 and show the matching fortune. Show a smile if good or frown if not */
To change the picture use this code: picture.setIcon(new ImageIcon("Frown.gif"));