Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTree and JPanel

843807Apr 21 2010 — edited Apr 21 2010
I have an application in which I have two separate dialog boxes that have multiple tabs (Panels) on them to set program options. I would like to update this UI to have a single dialog box that has a JTree on the left hand side of the dialog and have it update the Panel on the right hand side of the dialog. I am not 100% certain of how to achieve this. There are 2 issues

1) How to I update the panel corresponding to the node clicked in the JTree. I assume I need to add a listener so when a node is clicked I need to update the JPanel.

2) I assume that I do not want to create/destroy each JPanel associated with each JTree entry whenever a node is clicked. This would imply creating all JPanels when the dialog box is created. Do I create another JPanel/ScrollPane for the right hand side of the dialog box as a container and add these individual JPanels to it?

The Dialog box looks similar to

LHS RHS
JTree JPanel (changes based on JTree node selected)


The JTree looks similar to the following:
Options
   Global
      Connections
      Storage Options
      ...
   Session
      Filters
      Lists
TIA
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2010
Added on Apr 21 2010
6 comments
473 views