Window resize event?

Tags: ,



I’m writing a simple painting program using java, and I want some method to be called whenever the JFrame component is resized. But I can’t find any method like windowResizedListener or an event like windowResizedEvent. what can I do?!

Answer

Implement a ComponentAdapter with componentResized():

frame.addComponentListener(new ComponentAdapter() {
    public void componentResized(ComponentEvent componentEvent) {
        // do stuff
    }
});


Source: stackoverflow