How To Get Selected Node Text From JTree Using Java NetBeans
In this Java Tutorial we will see How To Get The Selected JTree Node Text Using DefaultMutableTreeNode And Display The Value Into A JTextFields On JTree Mouse Clicked Event In Java NetBeans .
Project Source Code:
private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
jTextField1.setText(selectedNode.getUserObject().toString());
}