import java.awt.*; import java.awt.event.*; public class maj extends Frame implements MouseListener { int x,y; public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mousePressed(MouseEvent e){ Graphics g=this.getGraphics(); do{ for(int t=-45;t<=45;t++){ x=(int)(150*Math.sin(3.14*t/180)); y=(int)(150*Math.cos(3.15*t/180)); g.setColor(Color.blue); g.drawLine(150,100,150+x,100+y); g.drawOval(135+x,100+y,30,30); try{ Thread.sleep(30);}catch(Exception ex){} g.clearRect(0,0,300,300); } for(int t=45;t>=-45;t--){ x=(int)(150*Math.sin(3.14*t/180)); y=(int)(150*Math.cos(3.15*t/180)); g.setColor(Color.blue); g.drawLine(150,100,150+x,100+y); g.drawOval(135+x,100+y,30,30); try{ Thread.sleep(30);}catch(Exception ex){} g.clearRect(0,0,300,300); } }while(true); } public static void main(String arg[]){ maj k=new maj(); k.setSize(300,300); k.setVisible(true); k.addMouseListener(k); } }