Problem

For each JApplet you create in the following exercises, create an HTML host document named...

For each JApplet you create in the following exercises, create an HTML host document named Test plus the JApplet name. For example, the host document for the JRiddle.java file is named TestJRiddle.html.

Create a JApplet that paints an ImageIcon the first time its paint() method is called, and then randomly draws small filled ovals in the background color over the image each time a JButton is clicked. The resulting effect is that the image seems to be erased by an increasing number of small overlapping ovals. For example, if you place an ImageIcon at the coordinates contained in variables named startPosX and startPosY, you can create a series of 15-by-10 filled ovals placed randomly on the ImageIcon’s surface using the following for loop:

for(int count = 0; count < 20; ++count)

{

int x = (int) (Math.random() * imageWidth) + startPosX;

int y = (int) (Math.random() * imageHeight) + startPosY;

g.fillOval(x, y, 10, 10);

}

Save the file as JEraseImage.java.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 17
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT