import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Ring extends Applet implements MouseListener{ int x,y,i,u; public void init(){ addMouseListener(this); } public void paint(Graphics g){ g.setColor(Color.red); g.drawLine(0,20,200,220); g.drawLine(200,220,400,220); } public void mousePressed(MouseEvent e){ x=e.getX(); y=e.getY(); if(x<150 && y<150 && (x-y)<1){ Graphics v=getGraphics(); for(i=0;i<(200-x);i++){ v.setColor(Color.red); v.drawLine(0,20,200,220); v.fillOval(x+i,y+i,20,20); try{Thread.sleep(10-(i/20));}catch(Exception r){} v.setColor(Color.white); v.fillOval(x+i,y+i,20,20); } for(u=0;u<200;u++){ v.setColor(Color.red); v.drawLine(200,220,400,220); v.fillOval(x+i+u,y+i,20,20); try{Thread.sleep(1+i/5);}catch(Exception r){} v.setColor(Color.white); v.fillOval(x+i+u,y+i,20,20); } } } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} }