I have a program that can be run as both an application (uses JFrame) and an applet (uses JApplet).
Both display a JPanel that I call TopPanel which has several sub-components and a Border layout. Both display a JMenuBar (attached to the JFrame for the application, and to the JApplet for the applet).
One of the items in the menu bar allows a change of a configuration element and that would ideally include a resizing of the subpanel on TopPanel which hosts that element.
As far as I can tell, removing and adding that subpanel (also a JPanel) doesn’t result in a new display, even when the new subpanel has a new preferredSize(). The only way I’ve figured out to get the display to respond to the changes is to execute a pack() method at the JFrame.
pack(), however, is a method of Window, and JApplet is not a subclass. Is there an equivalent method to pack() that can be used for the applet form of this program?
Is there a better way to get the TopPanel (fills entire JFrame or JApplet) to redisplay?
I’m considering the possibility that there IS a simpler way but that I executed it incorrectly…
Thanks for help!