JTree Selection

J

Jason Cavett

It is easy to determine what node has been selected in a JTree, but I
cannot determine when a node is not being selected. For example, if
the user clicks in the white space outside a JTree, every node on the
tree should be deselected. I know the JTree has a clearSelection()
method, but I can't figure out how to determine whether the user
clicked in the white space or on a node.

Any help would be much appreciated. Thanks.
 
D

Daniel Kastner

Jason said:
It is easy to determine what node has been selected in a JTree, but I
cannot determine when a node is not being selected. For example, if
the user clicks in the white space outside a JTree, every node on the
tree should be deselected. I know the JTree has a clearSelection()
method, but I can't figure out how to determine whether the user
clicked in the white space or on a node.

Any help would be much appreciated. Thanks.
Who about this: When you click a node usually a propertyChange ist fired. If you monitor the
mouse clicks an no propertyChange is fired doesn't this mean that the user has clicked in the
white space?


Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top