// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class SomeJFrame extends JFrame {
    private JPanel p;
    private JLabel lbl;
    public SomeJFrame() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());
        p = new SomeJPanel(this);
        add(p, BorderLayout.CENTER);
        lbl = new JLabel("            ");
        add(lbl, BorderLayout.SOUTH);
        pack();
    }
    public void done() {
        lbl.setText("Du klikkede");
    }
    public static void main(String[] args) {
        JFrame f = new SomeJFrame();
        f.setVisible(true);
    }
}

class SomeJPanel extends JPanel implements ActionListener {
    private SomeJFrame sf;
    private JButton btn;
    public SomeJPanel(SomeJFrame sf) {
        this.sf = sf;
        btn = new JButton("Klik her");
        btn.addActionListener(this);
        add(btn);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        sf.done();
    }
}
