Please help,
I'm trying to create an applet that paints an image icon the first time its paint method is called (which I was able to do), the problem I'm having is trying to get ovals to randomly fill the background and cover the image when the "press" button is clicked. Any help would be greatly appreciated:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
public class JEraseImage extends JApplet implements ActionListener
{
ImageIcon image = new ImageIcon("event.gif");
JButton press = new JButton("press");
int width, height;
Container con = getContentPane();
public void init()
{
con.setLayout(new FlowLayout());
press.addActionListener(this);
con.add(press);
width = image.getIconWidth();
height = image.getIconHeight();
}
public void actionPerformed(ActionEvent event)
{
width = width * 2;
height = height * 2;
}
public void paint(Graphics g)
{
g.drawImage(image.getImage(), 150, 100, width, height, this);
press.repaint();
for(int count = 0; count < 20; ++count)
{
int x = (int) (Math.random() * imageWidth) + startPosX;
int y = (int) (Math.tandon() * imageHeight) + startPosY;
g.fillOval(x, y, 150, 100);
}
}
}