List of usage examples for javax.swing.tree DefaultMutableTreeNode getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:ubic.basecode.dataStructure.graph.DirectedGraph.java
/** * Generate a JTree corresponding to this graph. * // w w w.j a va 2 s . c o m * @param nodeClass The class to be used for TreeNodes. Defaults to DefaultMutableTreeNode. * @return javax.swing.JTree */ @SuppressWarnings("unchecked") public JTree treeView(Class<? extends DefaultMutableTreeNode> nodeClass) { log.debug("Constructing tree view of graph"); DirectedGraphNode<K, V> root = getRoot(); Constructor<DefaultMutableTreeNode> constructor; DefaultMutableTreeNode top = null; treeView = null; try { constructor = (Constructor<DefaultMutableTreeNode>) nodeClass .getConstructor(new Class[] { root.getClass() }); top = constructor.newInstance(new Object[] { root }); log.debug("Starting tree with: " + top.getClass().getName()); root.mark(); addJTreeNode(top, root, constructor); dtm = new DefaultTreeModel(top); treeView = new JTree(dtm); } catch (Exception e) { log.error(e, e); } return treeView; }