public class Nnnn extends Applet implements Runnable , MouseListener
{
int x,y,str,r=0,s=0;
Thread t;
public void init()
{
setBackground(Color.yellow);
if(t==null)
{
t=new Thread(this);
t.start();
}
addMouseListener(this);
}
public void run()
{
while(true)
{
try
{
t.sleep(1000);
}
catch (InterruptedException e)
{
}
repaint();
}
}
public void paint(Graphics g)
{
Font f=new Font("arial",Font.BOLD,24);
g.setFont(f);
Random r=new Random();
x=r.nextInt()%450;
if(x<0)
x=x*(-1);
y=r.nextInt()%450;
if(y<0)
y=y*(-1);
if(x<30)
x=35;
if(y<30)
y=35;
g.setColor(Color.red);
g.fillOval(x,y,25,25);
showStatus(str+" click the ball to get a point");
g.drawString("POINTS :"+str,10,50);
}
public void mouseClicked(MouseEvent e)
{
r=e.getX();
s=e.getY();
if((r<=x+25&&r>=x-25)||(s<=y+25&&s>=y-25) )
{
str+=1;
}
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
}