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?!
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?!
Implement a ComponentAdapter with componentResized():
frame.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent componentEvent) {
// do stuff
}
});
Overriding particular methods of ComponentAdapter is a convenient alternative to implementing all the methods of ComponentListener. Several examples seen here illustrate the "convenience for creating listener objects" mentioned in the API.