All pastes #955731 Raw Edit

Info

public java v1 · immutable
#955731 ·published 2008-03-24 20:29 UTC
rendered paste body
import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.*;import javax.swing.*;/** * * @author Robin */public class Info extends JDialog implements ActionListener{        private JTextArea tekstveld;    private JButton edit, ok;        public Info(JFrame frame){        String tekst = "";        try {           FileReader file = new FileReader("hoi.txt");           BufferedReader in = new BufferedReader(file);           String s = in.readLine();           while (s != null){               tekst += s;               tekst += "\n";               s = in.readLine();           }           in.close();        }                catch (IOException io){}                tekstveld = new JTextArea(tekst, 8, 20);        tekstveld.setEnabled(false);        edit = new JButton("edit");        ok = new JButton("ok");                add(tekstveld);        add(edit);        add(ok);                edit.addActionListener(this);        ok.addActionListener(this);                setLayout(new FlowLayout());    }    public void actionPerformed(ActionEvent e) {        if (e.getSource() == edit){            tekstveld.setEnabled(true);                    }        if (e.getSource()== ok){            try {                PrintWriter schrijven = new PrintWriter("hoi.txt");                String tekst = tekstveld.getText();                schrijven.println(tekst);                schrijven.close();                                }            catch (IOException io){}        this.setVisible(false);                        }    }}