It would be a good idea to expose the ActionListener expansionListener in the class "Tree" so that one can simulate expanding/collapsing a node.
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.
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...
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?
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);
where targetComponent is the node i want to expand/collapse
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.
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...
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.