INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Need help in Dynaminc tree

Need help in Dynaminc tree

(OP)
i want to create  dynamic javatree in applet .and have to perform the(update functions on tree nodes)
Can any one help me to write the coding.
..............

package jtreeevent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;

public class Channel extends JApplet {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    JTree tree;
    JTextField jtf ;
    
    
    public void init(){
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        DefaultMutableTreeNode top = new DefaultMutableTreeNode("channel");
        
        
        
        DefaultMutableTreeNode english = new DefaultMutableTreeNode("English");
        
        top.add(english);
        
        DefaultMutableTreeNode english1 = new DefaultMutableTreeNode("English CH1");
        
        english.add(english1);
        
        DefaultMutableTreeNode english2 = new DefaultMutableTreeNode("English CH2");
        
        english.add(english2);
        
        
         DefaultMutableTreeNode english3 = new DefaultMutableTreeNode("English CH3");
            
            english.add(english3);
            
            
        
        DefaultMutableTreeNode deutsch = new DefaultMutableTreeNode("Deutsch");
        
        top.add(deutsch);
        
        DefaultMutableTreeNode deutsch1 = new DefaultMutableTreeNode("deutsch CH1");
        
        deutsch.add(deutsch1);
        
        DefaultMutableTreeNode deutsch2 = new DefaultMutableTreeNode("deutsch CH2");
        
        deutsch.add(deutsch2);
        
        tree = new JTree(top);
        
        
        int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
        
        int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
        JScrollPane jsp = new JScrollPane(tree,v,h);
        
        
        contentPane.add(jsp,BorderLayout.CENTER);
        jtf = new JTextField ("",20);
        contentPane.add(jtf,BorderLayout.SOUTH);
        
        
        tree.addMouseListener(new MouseAdapter()
        {
            public void mouseClicked(MouseEvent me){
                doMouseClicked(me);
                
            }
        
        });
        }
       void doMouseClicked(MouseEvent me)
       {
          TreePath tp = tree.getPathForLocation(me.getX (), me.getY());
          if (tp != null)
              jtf.setText(tp.toString());
          else
              jtf.setText("");
          
       }
        
        }
    ...............
In this above coding i  gave the input and getting the output inside the coding itself. but i need the same result without giving ( for eg :english) in the coding.
the result must be instantly create a dynamic tree form throught the conataining website(update functions on tree nodes).
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close