jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Problems using JTree and JTabbedPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problems using JTree and JTabbedPane" Watch "Problems using JTree and JTabbedPane" New topic

Problems using JTree and JTabbedPane

Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I suspect this is an elementary problem, but I haven't found the solution yet. I'm working on a GUI consisting of a JTree on the left side of the frame and one of three tabbed panes in the center. Which of the three is displayed depends on which JTree node is selected. The tabbed pane occupies a panel which has been added to the center of the content pane. The JTree listener removes the current tabbed pane from the panel and adds the next one.

Sometimes this causes the new pane to be displayed, but often it does not. If I resize the window, or temporarily obscure it with another window, the correct pane is displayed, so I know the components are being successfully added to the right containers. For some reason the window is not being repainted. I've tried calling validate() on numerous components but I haven't noticed any difference.

Cany anyone tell me how to fix this?


Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Your description of what you are doing and what isn't working the way you want is very clear and concise. This part of java is much too wonderful to figure out what you must/might have missed to produce the symptoms you describe. So it's easier to make up something that behaves correctly and (hopefully) does what you want.
I agree. Here's the link: http://aspose.com/file-tools
subject: Problems using JTree and JTabbedPane
It's not a secret anymore!