Skip to main content

animating expanding/collapsing of Tree nodes

6 replies [Last post]
ghady_rayess
Offline
Joined: 2009-01-09
Points: 0

Hello,
It would be a good idea to expose the ActionListener expansionListener in the class "Tree" so that one can simulate expanding/collapsing a node.
thanx

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Tree has animated expansions.
We don't expose features like that since that is an implementation detail which might change in a future release, we do provide callbacks when necessary.

ghady_rayess
Offline
Joined: 2009-01-09
Points: 0

I don't want to change the detail of the implementation. I think it would be a good idea to control the expansion of the tree from external events.
Let's say i have a form with a tree and I want to automatically expand the tree to a certain node. I won't be able to do that without access to the actionlistener...
Thanx

vprise
Offline
Joined: 2003-11-07
Points: 0

So if I get this strait what you want isn't the listener, you want a public expand/collapse node method that will accept model data (not a component). Right?

ghady_rayess
Offline
Joined: 2009-01-09
Points: 0

it could be just a public expand collapse method that accepts a component as parameter.
currently i do something like that:
ActionEvent ac = new ActionEvent(targetComponent, 1);
tree.getExpansionListener().actionPerformed(ac);
where targetComponent is the node i want to expand/collapse

vprise
Offline
Joined: 2003-11-07
Points: 0

The main issue with that is getting access to the Component, you will be relying on implementation specific behaviors which might change in a future version.
The "right thing" to do is similar to what the Swing tree did which is provide an expand method that accepts a "path" which is an array of objects from the root to the node. This isn't trivial, I just tried implementing this and it does require some work, please file an RFE on this so it doesn't get lost with my day to day tasks.
Thanks.

ghady_rayess
Offline
Joined: 2009-01-09
Points: 0

Well, all the user needs is a public method to collapse or expand a node. And those functions are already implemented in the Tree class but set as private "collapseNode(Component c)" & "expandeNode(Component c)".
Those methods can be set as public, or one method can simulate a button click and fire the Action listener on that component...