import java.awt.*; import java.io.*; import java.applet.Applet; import java.util.*; import java.awt.event.*; public class Punktid extends Applet implements MouseListener{ Button nupp=new Button("Tee ringid"); Button nupp2=new Button("Jookse ringi"); LinkedList x=new LinkedList(); LinkedList y=new LinkedList(); public Punktid(){ add(nupp); add(nupp2); nupp.addMouseListener(this); nupp2.addMouseListener(this); } public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mousePressed(MouseEvent e){ Graphics g=Punktid.this.getGraphics(); if(e.getSource()==nupp){ System.out.println("Nupp1"); try{ BufferedReader sisse=new BufferedReader(new FileReader("punktid.txt")); String rida=sisse.readLine(); while(rida!=null){ StringTokenizer stk=new StringTokenizer(rida); if(stk.countTokens()==2){ String k1=stk.nextToken(); String k2=stk.nextToken(); g.drawOval(Integer.parseInt(k1), Integer.parseInt(k2), 15, 15); }else{ System.out.println("Rida sisaldas liiga vähe võu palju koordinaate."); } rida=sisse.readLine(); } }catch(Exception ex){} } if(e.getSource()==nupp2){ System.out.println("Nupp2"); try{ BufferedReader sisse=new BufferedReader(new FileReader("punktid.txt")); String rida=sisse.readLine(); while(rida!=null){ StringTokenizer stk=new StringTokenizer(rida); if(stk.countTokens()==2){ String k1=stk.nextToken(); String k2=stk.nextToken(); x.add(k1); y.add(k2); }else{ System.out.println("Rida sisaldas liiga vähe võu palju koordinaate."); } rida=sisse.readLine(); } for(int i=0;i0;jupid--){ g.setColor(Color.red); g.fillOval(x, y, 15, 15); try{Thread.sleep(100);}catch(Exception ex){} g.setColor(Color.white); g.fillOval(x, y, 15, 15); x=x+alus1; y=y+alus2; //jupid--; } } x.clear(); y.clear(); //System.out.println("X-i suurus: "+x.size()); rida=""; }catch(Exception ex){} } } public void mouseReleased(MouseEvent e){} public static void main (String args[]){ Frame f=new Frame("Punktid"); f.setSize(600, 600); f.add(new Punktid()); f.setVisible(true); } }