| Author |
Custom Multiple Selection for JTree
|
Vitaly Karnyushin
Greenhorn
Joined: Apr 23, 2010
Posts: 1
|
|
Hi,
I need to implement specific multiple selection behavior.
The multiple selection should be worked for the nodes of one level.
As an illustration, if I have two expanded nodes with some amount of children in my view and one of the parents is already selected then multiple selection action should select only second one parent, children should be ignored.
Any advices how to properly implement that?
Thanks,
Vitaly
|
 |
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
|
|
John Golt wrote:I need to implement specific multiple selection behavior.
The multiple selection should be worked for the nodes of one level.
As an illustration, if I have two expanded nodes with some amount of children in my view and one of the parents is already selected then multiple selection action should select only second one parent, children should be ignored.
Any advices how to properly implement that?
I'm not I understand exactly what you want (Do you really want selection to behave differently depending on whether a node is currently visible in the view??) but have you looked at the TreeSelectionModel interface? You can write your own and do anything you want in the addSelectionPath() addSelectionPaths() methods, including ignoring certain paths, or substituting others, or deselecting others. You just have to make sure you fire the correct events.
It may be easier to extend DefaultTreeSelectionModel, since it provides and implementation for most of the event stuff.
|
bitguru blog
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8436
|
|
John Golt wrote:
Please check your private messages for an important administrative matter
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
 |
|
|
subject: Custom Multiple Selection for JTree
|
|
|