| Author |
JTree problem
|
Krithika Beri
Ranch Hand
Joined: Sep 11, 2012
Posts: 36
|
|
I have an option to browse multiple files. When i browse for a xml file, it appears in jtree form in the pane. When i click on the 2nd opened tree, it is showing the 1st opened tree.
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 921
|
|
I am not able to understand anything about this problem. Nor does the code explain anything.
You need to TellTheDetails.
you say multiple files, so are you showing each file in a separate tab? does each of this tab show a tree?
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
Krithika Beri
Ranch Hand
Joined: Sep 11, 2012
Posts: 36
|
|
|
I've got only one pane and in that pane only the JTree is displayed. When i browse for a new file, the old tree is to be replaced by the new tree. The first "browse" method is the ActionListener when you want to browse for a new file. I want to know what probably could be the cause for this error. I think you can ignore the list selection listener that i put there.
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 921
|
|
Ok. I see that you add the JScollPane (that has the JTree) to a JPanel named pane2 (I assume pane2 is a JPanel as you have not provided that info).
If so, what is the LayoutManager used for that JPanel? You are adding a new JScrollPane. What about the old one. Should you not remove it first?
Also, why are you using setBounds? I don't think it is needed. Ideally, you should have this pane2 use a BorderLayout with the JScollPane added to the center.
In fact, you should update the tree's model rather than create a new JTree everytime.
|
 |
Krithika Beri
Ranch Hand
Joined: Sep 11, 2012
Posts: 36
|
|
I only declared the scroll pane earlier, did not initialize it. I am re-initializing it every time. I have a JPanel and in that many other components like a list, tables etc. The tree is a part of it
|
 |
 |
|
|
subject: JTree problem
|
|
|