import java.awt.*; import java.applet.*; import java.io.*; import java.awt.event.*; public class Program extends Applet implements ActionListener { Button mentesGomb; TextField nevMezo; public void init() { setLayout(new FlowLayout()); mentesGomb = new Button("Ment"); nevMezo = new TextField(35); add(mentesGomb); add(nevMezo); mentesGomb.addActionListener(this); } public void actionPerformed(ActionEvent evt) { if (evt.getSource() == mentesGomb) { String s = nevMezo.getText(); System.out.println("Eredmény: " + s); try { File f = new File("adat.txt"); FileWriter kifolyam = new FileWriter(f, true); PrintWriter kimenet = new PrintWriter(kifolyam); kimenet.println(s); kimenet.close(); } catch(IOException e) { System.out.println("Hiba a fájlba írás közben!"); } } } /* actionPermormed */ }