import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class lr1 extends Applet implements MouseListener{ Choice c=new Choice(); public void init(){ addMouseListener(this); add(c); c.addItem("Slow"); c.addItem("Speed"); c.addItem("Fast"); } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mousePressed(MouseEvent e){ Graphics g=getGraphics(); g.setColor(new Color(e.getX()+e.getY(), e.getX(), e.getY())); String c2=c.getSelectedItem(); if(c2.equals("Slow")){ for(int x=40; x<240; x=x+2){ g.setColor(Color.red); int ooteaeg=4; int raadius=10; g.drawOval( 20+x+(int)(raadius*Math.cos(x/10.0))-10, 110+(int)(raadius*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25, 25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90, 20); int keskx=getSize().width/20; int kesky=getSize().height/20; try{Thread.sleep(50);}catch(Exception r){} g.setColor(Color.white); g.drawOval( 20+x+(int)(raadius*Math.cos(x/10.0))-10, 110+(int)(raadius*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25,25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90, 20); } } if(c2.equals("Speed")){ for(int x=40; x<240; x=x+6){ g.setColor(Color.red); int ooteaeg1=4; int raadius1=10; g.drawOval( 20+x+(int)(raadius1*Math.cos(x/10.0))-10, 110+(int)(raadius1*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25, 25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90,20); try{Thread.sleep(50);}catch(Exception r){} g.setColor(Color.white); int ooteaeg=4; int raadius=10; g.drawOval( 20+x+(int)(raadius1*Math.cos(x/10.0))-10, 110+(int)(raadius1*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25, 25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90, 20); } } if(c2.equals("Fast")){ for(int x=40; x<240; x=x+15){ g.setColor(Color.red); int ooteaeg2=4; int raadius2=10; g.drawOval( 20+x+(int)(raadius2*Math.cos(x/10.0))-10, 110+(int)(raadius2*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25, 25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90, 20); try{Thread.sleep(50);}catch(Exception r){} g.setColor(Color.white); g.drawOval( 20+x+(int)(raadius2*Math.cos(x/10.0))-10, 110+(int)(raadius2*Math.sin(x/10.0))-10, 6, 6 ); g.drawOval(x, 90, 25, 25); g.drawOval(x+50, 90, 25, 25); g.drawRect(x, 68, 90, 20); } } } }