JDK-6210002 : Undefined behavior of DefaultTreeSelectionModel.getSelectionPath() after setSelectionPaths
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-12-17
  • Updated: 2017-05-16
  • Resolved: 2007-02-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 Other
7 b07Fixed OpenJDK6Fixed
Related Reports
Relates :  
Relates :  
Description
If we select several nodes using DefaultTreeSelectionModel.setSelectionPaths it's not quite clear which path in selection will be first. In other words what is the result of getSelectionPath() is undefined. It's not necessary first element of passed in TreePath array. It'll be useful to clarify this situation in the spec.
###@###.### 2004-12-17 12:17:44 GMT

This is closely connected with following JTree.getLastSelectedPathComponent problem.
By description:
	Returns the last path component in the first node of the current selection.

getMinSelectionRow() returns the first selected row. But when we call getlastSelectedPathComponent it can return node, not corresponding to first selected row. See example in comments.
###@###.### 2004-12-17 14:02:37 GMT

Comments
EVALUATION Add the order of the rows returned by getSelectionRows() is corresponding to the order used in setSelectionRows(). Also verified that getLastSelectedPathComponent() component return component from the first selected row.
12-02-2007

EVALUATION In fixing this, I'm also going to change the getter that returns an array to return an empty array, rather than null. Returning null is too painful for callers to deal with, and is discouraged.
22-11-2006

EVALUATION The implementation internally creates a Hashtable, then uses an Iterator to create an array from that. As the ordering of the Iterator is undefined, so is the resulting order of getSelectionPaths and getPaths. This is bogus though, the order returned from getSelectionPaths should match that of setSelectionPaths.
13-11-2006

EVALUATION Yes, this should be firmed up in the spec. ###@###.### 2005-07-12 19:37:39 GMT
12-07-2005