import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*; 
import java.io.*;

class Opgave17_1 extends JFrame implements ActionListener {

    private JTextField inputField1;
    private JTextField inputField2;    
    private JLabel  inputLabel1, inputLabel2;
    private JButton button;
    private PrintWriter outFile;

    public static void main(String[] args) {
        Opgave17_1 frame = new Opgave17_1();
        frame.setSize(400, 150);
        frame.createGUI();
        frame.show();
    }

    private void createGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new FlowLayout());

        inputLabel1 = new JLabel("Naam: ");
        window.add(inputLabel1);         

        inputField1 = new JTextField(10);
        window.add(inputField1);
        
        inputLabel2 = new JLabel("Adres: ");
        window.add(inputLabel2);
        
        inputField2 = new JTextField(10);
        window.add(inputField2);

        button = new JButton("Bewaar !");
        window.add(button);
        button.addActionListener(this);

       
    }

    public void actionPerformed(ActionEvent event) {
        if (event.getSource() == button) {
            
           
            try{

                //vul de code aan met één regel ...

                outFile.print(inputField1.getText());
                outFile.println();
                outFile.print(inputField2.getText());
                outFile.close();
            }
            catch (IOException e) {
                JOptionPane.showMessageDialog(null, 
                    "File Error: " + e.toString());
            }
        }
    }
}
