import java.applet.Applet;
import java.awt.*;
import java.math.*;
/*<applet code="pro" height=100 width=100></applet>
*/
public class pro extends Applet implements Runnable
{
Thread t;
public void init()
{
t=new Thread(this);
t.start();
}
public void run()
{
try
{
while(true)
{
repaint();
t.sleep(1000);
}
}catch(Exception e)
{
System.out.println(e);
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
setBackground(Color.black);
Dimension d=this.getSize();
double x=Math.random()*d.width;
double y=Math.random()*d.height;
setForeground(Color.blue);
g.fillRect((int)x,(int)y,50,50);
}
}
import java.awt.*;
import java.math.*;
/*<applet code="pro" height=100 width=100></applet>
*/
public class pro extends Applet implements Runnable
{
Thread t;
public void init()
{
t=new Thread(this);
t.start();
}
public void run()
{
try
{
while(true)
{
repaint();
t.sleep(1000);
}
}catch(Exception e)
{
System.out.println(e);
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
setBackground(Color.black);
Dimension d=this.getSize();
double x=Math.random()*d.width;
double y=Math.random()*d.height;
setForeground(Color.blue);
g.fillRect((int)x,(int)y,50,50);
}
}
Comments