// reorder the nodes private void reorder(Vector nodes) { debug("reorder nodes"); // remove all the children of topNode (they'll be added back later) topNode.removeAllChildren(); // Create an array of the elements for sorting & copy the elements // into the array. DefaultMutableTreeNode[] array = new DefaultMutableTreeNode[nodes.size()]; nodes.copyInto(array); // Sort the array (Quick Sort) quickSort(array, 0, array.length - 1); // Reload the topNode. Everthing is in order now. for (int i = 0; i < array.length; i++) { topNode.add((DefaultMutableTreeNode) array[i]); } // Tell the tree to repaint itself ((DefaultTreeModel) tree.getModel()).reload(); tree.invalidate(); tree.repaint(); }