Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JTree Selection Customization

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic