import java.applet.Applet; import java.io.*; import java.awt.*; import java.awt.event.*; public class tahed extends Applet implements ActionListener{ TextField tf=new TextField(50); Button start=new Button("Start"); public tahed(){ add(new Label ("Tulemus:")); add(tf); add(start); start.addActionListener(this); } public void actionPerformed(ActionEvent e){ if (e.getSource()==start){ try{ BufferedReader sisse=new BufferedReader( new FileReader("fail.txt") ); int olemas=0; String rida=""; rida=sisse.readLine(); String esimene=rida; while((rida=sisse.readLine())!=null){ System.out.println(rida); if(rida.equals(esimene)){ olemas=olemas+1; } // if võrdluse sulg } // while sulg tf.setText("Leiti "+(olemas+1)+" esimesega sarnast"); System.out.println("Esimest kombinatsiooni leidub "+(olemas+1)+"tykki"); sisse.close(); }catch(IOException viga){viga.printStackTrace();} }// if Start sulg }//ActionPerformed sulg public static void main(String argumendid[]) throws IOException{ Frame f=new Frame (); f.setSize(600, 400); f.add(new tahed()); f.setLocation(300, 400); f.setVisible(true); f.addWindowListener(new aknaKuular()); // akna sulgemiseks } } class aknaKuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }