Skip to content
Advertisement

Window resize event?

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

Advertisement

Answer

Implement a ComponentAdapter with componentResized():

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