/**Populates the <code>node</code> argument with items retrieved from the collection. * Actually, the method delegates to {@link populateNode{String[], String[], DefaultMutableTreeNode)}. * @param collection Hashtable with `keys' (java.lang.String) representing a tree path which * is to be added to this node, but excludes it; the path extends to the last child (leaf node). * The `values' are (java.lang.String) as labels and user objects for the last child of the path. * Actually, <code><strong>null<strong></code> elements for labels are allowed, in which case * the last child will be constructed on the last token in the `key'. * @param node The TreeNode to be populated. */ private void populateNode(Hashtable collection, DefaultMutableTreeNode node) { Vector labelVector = new Vector(); for (Enumeration e=collection.keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); labelVector.addElement(key); } String[] labels = new String[labelVector.size()]; String[] items = new String[labelVector.size()]; labelVector.copyInto((String[])labels); // keys into labels[] StringSorter.sort(labels); for(int i=0; i<labels.length; i++) { items[i] = (String)collection.get(labels[i]); //values into items[] } populateNode(items,labels,node); }
/**Populates the <code>node</code> argument with items retrieved from the collection. * Actually, the method delegates to {@link populateNode{String[], String[], DefaultMutableTreeNode)}. * @param collection Hashtable with `keys' (java.lang.String) representing a tree path which * is to be added to this node, but excludes it; the path extends to the last child (leaf node). * The `values' are (java.lang.String) as labels and user objects for the last child of the path. * Actually, <code><strong>null<strong></code> elements for labels are allowed, in which case * the last child will be constructed on the last token in the `key'. * @param node The TreeNode to be populated. */ private void populateNode(Hashtable collection, DefaultMutableTreeNode node) { Vector labelVector = new Vector(); for (Enumeration e=collection.keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); labelVector.addElement(key); } String[] labels = new String[labelVector.size()]; String[] items = new String[labelVector.size()]; labelVector.copyInto((String[])labels); // keys into labels[] StringSorter.sort(labels); for(int i=0; i<labels.length; i++) { items[i] = (String)collection.get(labels[i]); //values into items[] } populateNode(items,labels,node); }