I’ve a window and since I dinamically change it’s children (sometimes I swap JPanels), I found no other solution than calling pack() on the window to get the new element displayed. Otherwise it will show up only if I resize manually the window.
The problem with this is that the if the window is maximized, after pack() it won’t be anymore, which is not what I could give to the client.
Any clues?
First of all, I hope that you’re using
CardLayoutfor panel swapping, since this functionality is built into that particular layout manager. And typically, you’ll want to invokevalidate/revalidateandrepainton the container to refresh the display.See also: