How To Update Selected Node From JTree Using Java NetBeans
In this Java Tutorial we will see How To Edit The Selected JTree Node With Value From JTextField Using DefaultMutableTreeNode On Button Click Event In Java NetBeans .
Project Source Code:
private void jButtonEditActionPerformed(java.awt.event.ActionEvent evt) {
// get selected node
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
selectedNode.setUserObject(jTextField1.getText());
DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
model.reload();
}