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!
  • Students Click Here

*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.

Students Click Here

Need help in Dynaminc tree

Need help in Dynaminc tree

Need help in Dynaminc tree

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");
        DefaultMutableTreeNode english1 = new DefaultMutableTreeNode("English CH1");
        DefaultMutableTreeNode english2 = new DefaultMutableTreeNode("English CH2");
         DefaultMutableTreeNode english3 = new DefaultMutableTreeNode("English CH3");
        DefaultMutableTreeNode deutsch = new DefaultMutableTreeNode("Deutsch");
        DefaultMutableTreeNode deutsch1 = new DefaultMutableTreeNode("deutsch CH1");
        DefaultMutableTreeNode deutsch2 = new DefaultMutableTreeNode("deutsch CH2");
        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);
        jtf = new JTextField ("",20);
        tree.addMouseListener(new MouseAdapter()
            public void mouseClicked(MouseEvent me){
       void doMouseClicked(MouseEvent me)
          TreePath tp = tree.getPathForLocation(me.getX (), me.getY());
          if (tp != null)
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! Already a Member? Login

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