I’m currently building a Java Swing GUI and I was wondering how user (mouse, say) driven resizing is handled.
My problem is that when I try and resize my main window, or when some other window opens over my application, then my application’s window gets distorted – all it’s parts don’t change well in response to the resizing or the other window. Does anyone have a diagnostic on where to start looking at this? Follow-ups questions, resources are also appreciated.
Cheers.
While Rob is correct that a ComponentListener will give you a callback for when the panel is resized, you should not have to use that in order to make sure your GUI looks correct. Instead you should ensure that you have configured your LayoutManager appropriately to handle being resized. It can be a real pain in the neck to get resizing to work appropriately with the standard Layouts; I would highly recommend you check out MigLayout.