I am trying to make everything in my window change size when the window size is changed. I am making a custom UI and need to set the layout to null, but I also don't want the window to have a never-changing size. My solution to this is to figure out when the size has changed then update the components of the frame to match that size. How can I do that?
CodePudding user response:
You can define a componentResized method in a ComponentListener (or ComponentAdapter).
This was explained before: Window resize event?
CodePudding user response:
If I understand, you can use an componentListener, adding it to JFrame. I use it as:
addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e){
e.getComponent().getWidth();
e.getComponent().getHeight();
}
@Override
public void componentMoved(ComponentEvent e){
}
@Override
public void componentShown(ComponentEvent e){
}
@Override
public void componentHidden(ComponentEvent e){
}
});