Here it is:
[imports...]
public class Main extends JApplet implements Runnable
{
Random R = new Random();
Image img;
BufferedImage back;
public void paint(Graphics g)
{
int height = this.getSize().height;
int width = this.getSize().width;
Graphics2D g2d = (Graphics2D) g;
back = (BufferedImage) createImage(width, height);
Graphics2D back2d = (Graphics2D) back.getGraphics();
back2d.fillRect(0, 0, width, height);
for(int i = 0; i < 100; i++)
back2d.drawImage(img, R.nextInt(width), R.nextInt(height), null);
g2d.drawImage(back, 0, 0, null);
}
public void init()
{
try
{
img = ImageIO.read(new URL(getCodeBase(), "ff.png"));
Thread t = new Thread(this);
t.start();
}
catch (MalformedURLException ex)
{
ex.printStackTrace();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
public void run()
{
while(true)
{
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
}
Any reason why?