• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JTree problem

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Krithika Beri
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic