Lompat ke konten Lompat ke sidebar Lompat ke footer

Java Edit JTree Node

How To Update Selected Node From JTree Using Java NetBeans

 How To Update Selected Node From JTree Using Java NetBeans Java Edit JTree Node



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();
    } 


OutPut:

 How To Update Selected Node From JTree Using Java NetBeans Java Edit JTree Node




Posting Komentar untuk "Java Edit JTree Node"