Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31272
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jeff Higgins <jeff@invalid.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JTree add / remove nodes |
| Date | Thu, 05 Mar 2015 09:17:28 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 39 |
| Message-ID | <md9ogk$6lv$1@dont-email.me> (permalink) |
| References | <md8vkk$2905$1@ariadne.rz.tu-clausthal.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 5 Mar 2015 14:16:52 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="6847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4VZ7cevCZccKpPhCXbaAvSIyDLc7Jko0=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0 |
| In-Reply-To | <md8vkk$2905$1@ariadne.rz.tu-clausthal.de> |
| Cancel-Lock | sha1:2JqLus4f5NRYAIoz2RwbD9T1AgY= |
| Xref | csiph.com comp.lang.java.programmer:31272 |
Show key headers only | View raw
On 03/05/2015 02:12 AM, Philipp Kraus wrote: > Hello, > > > I have got a tree dataset and I would like to visualize the data with a > JTree component. The user should only brows in the tree, so no > modifcation on the nodes is needed. JTree.DynamicUtilTreeNode has a static createChildren(DefaultMutableTreeNode parent, Object children) method which is convenient for this. > > But I don't understand, which I can add and remove nodes from the tree. > I have created this data > > > *protected *DefaultMutableTreeNode *m_root *= *new > *DefaultMutableTreeNode( *"myRoot" *); > *protected final *JTree *m_tree *= *new *JTree( *m_root *); > *protected final *TreeModel *m_model *= *new *DefaultTreeModel( *m_root *); > > and an empty tree is shown. > > But how can I add at this new nodes? > My data are path strings like "root / subnode / subsubnode / leaf", so can I > addthe full path to my tree which node / leaf creation on the fly? > So I would push the the string to the tree and all parts should be created if > it not exists. At the same way I get a path which should remove from the tree. Now your tree has become dynamic? You are responsible for implementing these behaviors upon the TreeModel and MutableTreeNode interfaces. > > I'm a little bit overwhelmed with the JTree. >
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JTree add / remove nodes Philipp Kraus <philipp.kraus@flashpixx.de> - 2015-03-05 08:12 +0100
Re: JTree add / remove nodes Jeff Higgins <jeff@invalid.invalid> - 2015-03-05 09:17 -0500
Re: JTree add / remove nodes Philipp Kraus <philipp.kraus@flashpixx.de> - 2015-03-05 19:23 +0100
Re: JTree add / remove nodes Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-03-05 14:18 -0500
Re: JTree add / remove nodes Philipp Kraus <philipp.kraus@flashpixx.de> - 2015-03-05 23:59 +0100
Re: JTree add / remove nodes Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-03-05 18:28 -0500
csiph-web