get selected node jtree java
<p>Here is my <code>JTree</code></p>

<pre><code>javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(".Net Framework");
javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Install");
javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V1");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V2");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V3");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V4");
treeNode2.add(treeNode3);
treeNode1.add(treeNode2);

treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Repair");
treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V1");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V2");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V3");
treeNode2.add(treeNode3);

treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("V4");
treeNode2.add(treeNode3);
treeNode1.add(treeNode2);

treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Removal");
treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Remove All");
treeNode2.add(treeNode3);
treeNode1.add(treeNode2);

jTree2.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
jScrollPane5.setViewportView(jTree2);
</code></pre>

<p>here is the code that almost works</p>

<pre><code>DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree2.getLastSelectedPathComponent();

if (node == null) {
      //Nothing is selected.     
    return;
}

if (node.isLeaf()) {
    System.out.println(node);
} 
</code></pre>

<p>I want to be able to make if statements that say if leaf node V1 in the Install Node, then do this. Just not sure what to do with <code>if(node.equals(thisleaf)))</code>, what the <code>thisleaf</code> object should be equal to.</p>
