This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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.