Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4412870

getIndexOfChild in javax.swing.tree.TreeModel needs more specification

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • docs
    • beta
    • generic
    • generic, solaris_2.6



      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)
      ======================================================================

            sharonz Sharon Zakhour (Inactive)
            ssultanasunw Shaheen Sultana (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: