import java.io.RandomAccessFile; import java.io.*; import java.awt.*; import java.awt.event.*; public class Eksam2 extends Frame implements MouseListener{ public Eksam2(String args){ addMouseListener(this); this.argumendid0=args; } String argumendid0; void meetod() throws Exception{ String punkt, xs,ys; BufferedReader sisse=new BufferedReader(new FileReader("andmed.txt")); String rida=sisse.readLine(); System.out.println("Faili esimene rida on: "+rida); System.out.println("Nd j„rjestikku k„ik faili read:"); while(rida!=null){ System.out.println(rida); xs=rida.substring(0, rida.indexOf(" ")); ys=rida.substring(rida.indexOf(" ")); int x=Integer.parseInt(xs.trim()); int y=Integer.parseInt(ys.trim()); Graphics gr=this.getGraphics(); gr.drawOval(x,y,30,30); rida=sisse.readLine(); } // while lopp /* RandomAccessFile rf=new RandomAccessFile(argumendid0,"r"); punkt = rf.readLine(); String tulemus=""; punkt=rf.readLine(); while(punkt!=null){ tulemus=tulemus+punkt+" "; punkt= rf.readLine(); //while lopp */ } //meetod lopp public void mousePressed(MouseEvent e){ int x=e.getX(); int y=e.getY(); Graphics g=getGraphics(); g.drawOval(x-5, y-5,10, 10); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String argumendid[]) throws Exception{ Eksam2 f=new Eksam2(argumendid[0]); f.setSize(200, 300); f.setVisible(true); f.meetod() ; } }