import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.lang.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.*; public class Salvesta extends Applet implements ActionListener{ Label l=new Label("Kirjuta nimi"); TextField tf1=new TextField("",10); TextArea tf2=new TextArea("",4,30); Button edasi1=new Button("Salvesta"); Button edasi2=new Button("Vaata "); String aa2; Frame f; int punkte; public Salvesta(Frame a,int i){ f=a; punkte=i; add(l); add(tf1); add(edasi1); add(edasi2); add(tf2); edasi1.addActionListener(this); edasi2.addActionListener(this); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ f.dispose(); } }); } public void actionPerformed(ActionEvent e){ if(e.getSource()==edasi1){ String nimi=tf1.getText(); nimi=nimi+" "+punkte; tf1.setText(nimi); char[] ee = new char[nimi.length()]; int ag=2; for(int i=0; i(122-ag)){ n= 96+ag; } ee[i]=(char)n; } String aa=new String(ee); try{ PrintWriter valja=new PrintWriter( new FileWriter("inimesed.txt",true) ); valja.println(aa+"\n"); valja.close(); }catch(Exception ex){} } if(e.getSource()==edasi2){ try{ BufferedReader sisse=new BufferedReader( new FileReader("inimesed.txt") ); String rida=sisse.readLine(); while(rida!=null){ char[] ee = new char[rida.length()]; int ag=-2; for(int i=0; i(122-ag)){ n= 96+ag; } ee[i]=(char)n; } aa2=new String(ee); tf2.append(aa2+"\n"); rida=sisse.readLine(); } sisse.close(); }catch(Exception ex){} } } }