File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Change JFrame content pane without window resizing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Change JFrame content pane without window resizing" Watch "Change JFrame content pane without window resizing" New topic
Author

Change JFrame content pane without window resizing

Jon Brasted
Greenhorn

Joined: Mar 18, 2004
Posts: 19
Hi.

Inside a JFrame's container, I have a JPanel. I have a JScrollPane inside that which currently has a JTextArea object. Using a menu item, I want to be able to change the contents of the scroll pane to a JTree. I can currently do it by getting the JPanel and then adding a new JScollPane object containing the JTree. However, when I do so, the frame shrinks and then (nearly) instantly resizes. I want the frame to 'stay put'.

Is there any way of doing this?

Thanks,
Jon
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
can you post a sample program, similar to below, showing the problem.

simple demo from your description, seems to work OK

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Change JFrame content pane without window resizing