Name: ssT124754 Date: 02/07/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
In javax.swing.tree.TreeModel the method getIndexOfChild(Object parent, Object
child) doesn't specify what to do if the child is no longer underneath the
parent. This DOES happen. It's apparently expected to return -1 in that case
because in FixedHeightLayoutCache and VariableHeightLayoutCache it tests the
return value against -1 to see if this is the case, but in other Swing source
code it just test for < 0. The documentation for TreeModel should state to
return -1 in this case (as well as what to do in other methods like getChild
(Object parent, int index)) or something else, and then the other Swing code
should be made to match this.
This caused me problems because I was using Arrays.binarySearch to find child
inndices and just returning that value, and returning -2 from getIndexOfChild
breaks the LayoutCache stuff.
(Review ID: 116519)
======================================================================
- duplicates
-
JDK-4425722 TreeModel.getIndexOfChild javadoc might need return value defined for non-child
-
- Closed
-