🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10749

Re: VERY basic JTree question...

#10749
From: Jonathan
Date: Tue, 17 Aug 1999 00:00
43 lines
1675 bytes
JTree tree;


in the initialisation method do:

DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
DefaultMutableTreeNode parent1 = new DefaultMutableTreeNode("parent1");
parent1 = new DefaultMutableTreeNode("child11");
parent1= new DefaultMutableTreeNode("child12");
DefaultMutableTreeNode parent2 = new DefaultMutableTreeNode("parent2");
parent2 = new DefaultMutableTreeNode("child21");
parent2 = new DefaultMutableTreeNode("child22");

root.add(parent1);
root.add(parent2);

tree = new JTree(root);


This will work, but it is better to write a class which handles such data
and creation of nodes, but this will definately get you started

if you need any more help, just ask


Holger Stratmann wrote in message <37B97436.60A20FCB@cassiopeia.de>...
>This is just for starters: How do I insert a couple of nodes into a
>JTree?
>
>e.g. what's the code for
>* Root
>  |- Parent 1
>  |  |- Child 11
>  |  '- Child 12
>  '- Parent 2
>     '- Child 21
>
>I just keep getting lost in all those interfaces and abstract classes.
>Once I can create one parent and one child, I can probably just go on...
>
>Thanks a lot! :-)
>
>
Technical Details
Message-ID: <7pbslu$sci2@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37B97436.60A20FCB@cassiopeia.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,a250cac0519badf0
X-Google-Attributes: gid111d45,public
From: "Jonathan" <plaskowj@logica.com>
Subject: Re: VERY basic JTree question...
Date: 1999/08/17
Message-ID: <7pbslu$sci2@forums.borland.com>
X-Deja-AN: 513811339
References: <37B97436.60A20FCB@cassiopeia.de>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.swing