// 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.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

public class ResizeCatcher extends JFrame implements ComponentListener {
    public ResizeCatcher() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(200, 200);
        addComponentListener(this);
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame f = new ResizeCatcher();
                f.setVisible(true);
            }
        });
    }
    public void componentResized(ComponentEvent e) {
        if(!e.paramString().equals("COMPONENT_RESIZED (0,0 200x200)")) {
            JOptionPane.showMessageDialog(this, "My size is perfect thank you");
            setSize(200, 200);
        }
    }
    public void componentMoved(ComponentEvent e) {
    }
    public void componentShown(ComponentEvent e) {
    }
    public void componentHidden(ComponentEvent e) {
    }
}
