import java.awt.*; import java.awt.event.*;
import javax.swing.*;
public class FirstButton extends JFrame implements
                                        ActionListener {
    JLabel label;
    JButton button;
    public FirstButton() {
        setLayout(new FlowLayout());
        setSize(500,100);
        setVisible(true);
        setFont(new Font("SansSerif", Font.BOLD, 18));
        label = new JLabel();
        label.setText("This is my first button :-)");
        add(label);
        button = new JButton("Knopf");
        button.addActionListener(this);
        add(button);
        revalidate();
    }
    public void actionPerformed(ActionEvent e) {
        label.setText("Damn - you pressed it ...");
        System.out.println(e);
        remove(button);
        // layout manager recalculates positions
        revalidate(); 
        repaint();  
    }
    static class MyRunnable implements Runnable {
        public void run() {
            new FirstButton();
        }
    }
    public static void main(String args[]) {
        SwingUtilities.invokeLater(new MyRunnable());
    }
} // end of FirstButton
     
