JDK-4801246 : JTree should fire selection change notice on mouse up
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-01-10
  • Updated: 2017-05-23
Related Reports
Relates :  
Description

Name: jk109818			Date: 01/09/2003


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]

ADDITIONAL OPERATING SYSTEMS :

Should appear on all platforms


A DESCRIPTION OF THE PROBLEM :
JTree (BasicTreeUI) selects on mouse down. It SHOULD
highlight the selection-to-be on mouse down and effectuate
the actual selection on mouse up.

The problem with the current implementation is that it is
not possible to drag anything else than the current
selection. This is contrary to the standard paradigm for
dragging from a tree (i.e. how Windows Explorer behaves).

Imagine that you have a two panes where the left pane is a
tree and the right pane is content representing the
selected node in the tree (e.g. like Windows Explorer). It
should be possible to drag and drop one node into the
content pane representing another (the currently selected)
node.

This comment in BasicTreeUI.MouseHandler.handleSelection
(MouseEvent) supports my view:

// PENDING: Should select on mouse down, start a drag if
// the mouse moves, and fire selection change notice on
// mouse up. That is, the explorer highlights on mouse
// down, but doesn't update the pane to the right (and
// open the folder icon) until mouse up.


REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 178847) 
======================================================================

Comments
EVALUATION In order to highlight cells we need to change the selection model, in other words we need to update the model on mouse pressed/down. One way to solve this is by adding a set/getValueIsAdjusting method to the model as well as a getter to the event. So, the model would be updated as it is now but the event would have the isValueAdjusting property set to true, on mouse up the event would also be sent out, but isValueAdjusting would be false. This needs more investigation as this implies a new interface needs to be created and additionally it would mean all TreeSelectionListeners get double the events. ###@###.### 2003-01-14 I think this is very closely related to 4521075. Possibly a dup. ###@###.### 2003-01-16
14-01-2003