| Author |
Confused on how to make 3 random images in an applet
|
Mack Grill
Greenhorn
Joined: Feb 27, 2012
Posts: 29
|
|
I'm trying to make 3 random images gifs with one image having a string of text at the bottom. I need to make this in the applet class so I can't use the random class to simplify it.
The project also states that using the start () method will help as a random flag to determine which image is shown but I'm very confused on how I would write the statements.
here is the full text full the project to help clarify:
In your applet, randomly show an image when the applet is started or restarted. Also, print a message on the applet, depending on which image is shown. Hints: the start() method would be a good place to put some sort of random flag to determine which image should be shown. It is also a good place to call a separate method to set the image and message. The paint() method should only do the actual drawing of the image and the message. Separate methods can be created to set the image and the message into variables for the paint() method to use.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
Welcome to the Ranch
It appears you are not trying to make random .gifs, but select one of three randomly to display. I presume you know how to display a .gif on your applet with its paint() method, and how to select that .gif from a file?
|
 |
Mack Grill
Greenhorn
Joined: Feb 27, 2012
Posts: 29
|
|
Thank you! and yes, I do know how to display an image with the paint() method and how to select a file.
|
 |
dennis deems
Ranch Hand
Joined: Mar 12, 2011
Posts: 808
|
|
|
What have you tried so far?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
Mack Grill wrote:Thank you!  and yes, I do know how to display an image with the paint() method and how to select a file.
Now all you have to do is work out how to select one of three.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
|
You would know how to select one String, for example, out of three?
|
 |
Mack Grill
Greenhorn
Joined: Feb 27, 2012
Posts: 29
|
|
Could i use the if statement to determine which image would contain the string of text?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
|
I suggest you do the selection without the text first, and work out how to add the text later.
|
 |
 |
|
|
subject: Confused on how to make 3 random images in an applet
|
|
|