Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

To add an element dynamically , we will use three different classes.

Design Diagram for Tree:-

 public class TreeViewExample extends javax.swing.JFrame {

     * Creates new form TreeViewExample
    DefaultTreeModel model;
    public TreeViewExample() {
        model = (DefaultTreeModel) jTree1.getModel();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        DefaultMutableTreeNode root = (DefaultMutableTreeNode) jTree1.getModel().getRoot();
        DefaultMutableTreeNode child = new DefaultMutableTreeNode(jTextField1.getText());
        model.insertNodeInto(child, root, root.getChildCount());


Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post