import java.awt.*; import java.io.*; import java.awt.event.*; import java.applet.*; class uusaken extends Panel implements ActionListener { TextArea tekstikoht=new TextArea(21,15); Button salvesta=new Button("Salvesta"); Button katkesta=new Button("Katkesta"); Frame tekstiaken=new Frame(); Panel paneel_3=new Panel(new GridLayout(1,3)); TextField salvestatav=new TextField(); public uusaken(String puhver) { tekstikoht.setText(puhver); tekstiaken.setSize(400,400); setLayout(new BorderLayout()); paneel_3.add(salvestatav,BorderLayout.WEST); paneel_3.add(salvesta,BorderLayout.EAST); paneel_3.add(katkesta,BorderLayout.CENTER); tekstiaken.add(tekstikoht,BorderLayout.NORTH); tekstiaken.add(paneel_3,BorderLayout.SOUTH); salvesta.addActionListener(this); katkesta.addActionListener(this); tekstiaken.setVisible(true); } public void actionPerformed(ActionEvent uus) { if (uus.getSource()==katkesta) { tekstiaken.dispose(); } if (uus.getSource()==salvesta) { int arv=0; String parool=new String(); parool=salvestatav.getText(); while (parool.charAt(arv)!=' ') { arv++; } String failinimi=new String(); failinimi=parool.substring(0,arv); parool=parool.substring(arv+1); String tekst=tekstikoht.getText(); arv=tekst.length(); String kodeeritudtekst=""; int teinearv=0; int mitmestaht=0; for (int i=0;i=parool.length()) { mitmestaht=0; } } } try { PrintWriter valja=new PrintWriter( new FileWriter(failinimi) ); valja.println(kodeeritudtekst); valja.close(); repaint(); } catch(IOException viga){viga.printStackTrace();} } } } class avamisaken extends Panel implements ActionListener { Frame avamisaken=new Frame(); Panel paneel_2=new Panel(new GridLayout(2,2)); Button okei=new Button("OK"); Button katkesta=new Button("Katkesta"); TextField avatav=new TextField(); public avamisaken() { avamisaken.setSize(200,200); setLayout(new BorderLayout()); paneel_2.add(okei,BorderLayout.WEST); paneel_2.add(katkesta,BorderLayout.EAST); avamisaken.add(paneel_2,BorderLayout.SOUTH); avamisaken.add(avatav,BorderLayout.NORTH); okei.addActionListener(this); katkesta.addActionListener(this); avamisaken.setVisible(true); } public void actionPerformed(ActionEvent syndmus) { if (syndmus.getSource()==okei) { String kodeeritudtekst=""; String puhastekst=""; try { String parool=new String(); parool=avatav.getText(); int arv=0; while (parool.charAt(arv)!=' ') { arv++; } String failinimi=new String(); failinimi=parool.substring(0,arv); parool=parool.substring(arv+1); BufferedReader sisse=new BufferedReader(new FileReader(failinimi)); for(String h=sisse.readLine();h!=null;h=sisse.readLine()) { kodeeritudtekst=kodeeritudtekst+h+"\n"; } arv=kodeeritudtekst.length(); int kuspraegu=0; for (int i=0; i