import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BuchEingabe extends JPanel
                         implements ActionListener {

    protected JTextField textField;

    // Konstruktor, wir benutzen hier GridBagLayout
    public BuchEingabe() {
        super(new GridBagLayout());
        textField = new JTextField(20);
        textField.addActionListener(this);
        GridBagConstraints c = new GridBagConstraints();
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        add(textField, c);
        c.fill = GridBagConstraints.BOTH;
    }

    // was passiert bei einer Aktion ?
    public void actionPerformed(ActionEvent evt) {
        String text = textField.getText();
        // und nun ?
        textField.setText("Eingabe erkannt!");
    }

    // erzeuge das Eingabefenster
    private static void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("Buch eingeben:");
        frame.setDefaultCloseOperation(
                          JFrame.EXIT_ON_CLOSE);
        JComponent newContentPane = new BuchEingabe();
        newContentPane.setOpaque(true);
        frame.setContentPane(newContentPane);
        frame.pack();
        frame.setVisible(true);
    }

    // Hauptmethode
    public static void main(String[] args) {
                createAndShowGUI();
    }
}