• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTree - expanding nodes

 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I can't expand nodes and I don't know why. Here under is the code. It is supposed to create a frame and one tree wrapped in scroll pane, and there should be a button with "expand" written on it. When I click the "expand" button, I expected that tree node will expand, but it doesn't.

One more time, thanks.

 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The TreePath is incorrect. It's a path with only one element, o2. But it needs the parent as well, and the parent's parent, etc. Change it to the following to work:
 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You one more time.
Petar
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You,

Excuse me,
... I still can't make it to work. I appologize for taking time on such a basic things. I can't solve it. It is too much simple , and I don't know what I did wrong now, I can't really imagine what to do next, and I know that it could take me even days for something so simple. If you can see the code that I have made now, I would be very thankfull, and I appologiye one more time for my lack of knowledge and inspiration.

I have passed an array of Objects to the TreePath constructor, I suppose, and I have passed TreePath object to the expandPath method, but it doesn't expand nothing. I have an output to console, where I can see that I have the right Objects, and ... so I am confused...

I don't know how to thank enough.

 
Petar Thomas
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved my problem for now like this...

(sorry for bothering...)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic