import java.applet.Applet; import java.io.*; import java.awt.event.*; import java.awt.*; public class kodune2 extends Applet implements ActionListener{ TextField tf=new TextField("",10); TextField tf2=new TextField("",50); Button bt= new Button("vajuta"); public kodune2(){ Panel p=new Panel(new GridLayout(2, 1)); p.add(tf); p.add(tf2); add(p); add (bt); bt.addActionListener(this); } public void actionPerformed(ActionEvent e) { try{ int i; int j; BufferedReader sisse=new BufferedReader(new FileReader("test1.txt")); String laused=".!?"; String lause=""; String sonad=" "; int sonaalgus=0; int sonadearv=0; int sonadearv1=0; String rida=sisse.readLine(); while (rida!=null){ for (i=0; isonadearv){ sonadearv=sonadearv1; lause=rida; } sonadearv1=0; } } } rida=sisse.readLine(); } tf.setText("Kõige rohkem sõnu ühes lauses oli: "+sonadearv); tf2.setText("Lauseks on: "+ lause); sisse.close(); }catch(Exception a){ System.out.println("Probleem: "+a); } } public static void main(String argumendid[]){ Frame f=new Frame(); f.setSize(600, 150); f.add(new kodune2()); f.setVisible(true); f.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } } ); } }