/** * Inserts a node at the specified position in the child list. Will * throw an ArrayIndexOutOfBoundsException if the index does not exist. * @param index the position to insert at. * @param child the Node object to insert. * @throws IndexOutOfBoundsException if thrown. */ public void insertChildAt(int index, TreeNode child) throws IndexOutOfBoundsException { if(index==getNumberOfChildren()) { addChild(child); } else { if(children==null) children = new ArrayList(); children.add(index, child); } }