import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Testvraag7_4 extends JFrame implements ActionListener {

    private JButton button1, button2;
    private JTextField textField;   
    private JButton button3;


    public static void main(String[] args) {
        Testvraag7_4 demo = new Testvraag7_4();
        demo.setSize(100,100);
        demo.createGUI();
        demo.show();
    }

    private void createGUI() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container window = getContentPane();
        window.setLayout(new FlowLayout());

        button1 = new JButton("1");
        window.add(button1);
        button1.addActionListener(this);

        button2 = new JButton("2");
        window.add(button2);
        button2.addActionListener(this);
        
        button3 = new JButton("3");
        window.add(button3);
        button3.addActionListener(this);

        textField = new JTextField(6);
        window.add(textField);
    }

    public void actionPerformed(ActionEvent event) {
        Object source = event.getSource();
        
        if (source == button1) {
            textField.setText("button 1");
        }
        
        if (source == button2) {
            textField.setText("button 2");
        }
        
        if (source == button3) {
            textField.setText("button 3");
        }
        
       
    }
}

