aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTree - expanding nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree - expanding nodes" Watch "JTree - expanding nodes" New topic
Author

JTree - expanding nodes

Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Thank You one more time.
Petar
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

You're welcome
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
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

Joined: Oct 11, 2009
Posts: 234
I have solved my problem for now like this...

(sorry for bothering...)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree - expanding nodes