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

DefaultTreeModel and Vector docs should state that all elements must be unique

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • docs
    • beta
    • generic
    • generic



      Name: krT82822 Date: 03/16/99


      original synopsis: "JTree fails with duplicate children nodes under the same parent"

      JTree does not allow duplicate nodes to exist as children of the same parent. I don't believe there is any problem with duplicate nodes in the tree
      as long as it is duplicated under different parents.

      The problem is in the TreeModel interface. The function:
      int getIndexOfChild(Object parent, Object child);
      cannot return a correct value if the specified child node exists at multiple indices under the given parent.

      I encountered this limitation while using JTree to implement an editor of a complex object. The object was an animated character complete
      with sounds. At first JTree seemed like the perfect control for editing this object. I could put the JTree in the left panel of a JSplitPane and
      have both editing and preview panes on the right. The nodes of the tree are heterogeneous and include:
      sound clips,
      images,
      images composed of overlays of other images,
      foreground frames composed of an ordered sequence overlays,
      animations composed of an ordered sequence of foreground frames
      actions composed of an order sequence of animations or sounds

      JTree made it relatively easy for the user to visualize and edit a complicated object. Unfortunately many of the parent nodes may have duplicate
      children e.g. an animation node may contain duplicate foreground frames; an action node may contain duplicate sounds or animations.

      In this case it is undesireable to physically copy the duplicate children to make them work with the JTree. Duplication takes more resources and is
      thus unnecessary, but more importantly it is not logically desirable. If the user edits an animation, I would like that change reflected in any action
      that contains that animation.
      (Review ID: 55577)
      ======================================================================

            sharonz Sharon Zakhour (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: