Exemple #1
0
  /** Removes the given node from its parent. */
  public void removeNodeFromParent(MutableTreeNode node) {
    MutableTreeNode parent = (MutableTreeNode) node.getParent();

    // Ensure that the given node has a parent
    if (parent == null) {
      throw new IllegalArgumentException("node does not have a parent");
    }

    // Remove the node from the parent
    int idx = parent.getIndex(node);
    parent.remove(idx);

    // Notify listeners that the node has been removed
    fireTreeNodesRemoved(this, getPathToRoot(parent), new int[] {idx}, new Object[] {node});
  }
Exemple #2
0
 /** Inserts the given child node into the given parent at the given index. */
 public void insertNodeInto(MutableTreeNode child, MutableTreeNode parent, int idx) {
   parent.insert(child, idx);
   fireTreeNodesInserted(this, getPathToRoot(parent), new int[] {idx}, new Object[] {child});
 }