Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTree Selection Customization

 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented a DragAndDrop tree and want to control when treeSelection events get fired.

My tree allows selection of multiple nodes, you can ctrl+click on multiple nodes and they will all appear as selected. Single clicking on any of the selected nodes will change the selection to be just that node. I would like to change this so that a mouse pressed event on a selected node does not change the selction, but a mouse clicked or mouse released event does. This way, a user could press on a selection and drag the entire group elsewhere.

I assume to do this I need to extend whatever class owns the mouse listener that fires treeSelection events and customize the logic for when these events get fired. But I can't find this class.

Thank You
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't used TreeSelectionEvents much, so I cannot answer your question directly. But something that may help you is the following... and it may help you solve other problems in the future... If you go to the TreeSelectionEvent class, or any class or interface, in the JavaDoc API, at the top is a series of links with a light blue background: "Overview, Package, Class, Use, Tree, Deprecated, Index, Help". Click on the "Use" link. It will show you a list of all other (known) classes and methods that use that class. It will give you a list of methods that use that class as an argument, methods that return that class, public fields that have that class as a type, etc. In the case of the TreeSelectionEvent, there is a rather limited number methods that use it. From that you can probably find what you are looking for.

I hope that helps.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johann Dobbins wrote:I would like to change this so that a mouse pressed event on a selected node does not change the selction, but a mouse clicked or mouse released event does. This way, a user could press on a selection and drag the entire group elsewhere.


will do the trick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic