Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3970
| From | "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: JTree - subnode not a |
| Message-ID | <nospam-87B10E.01291813082008@aioe.org> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <g7to9c$m5q$1@registered.motzarella.org> |
| Date | 2011-04-27 15:47 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui In article <g7to9c$m5q$1@registered.motzarella.org>, Daniele Futtorovic <da.futt.news@laposte.invalid> wrote: > On 13/08/2008 05:43, pelakh@yahoo.com allegedly wrote: > > I have a simple JTree in one of my panels, using the > > DefaultTreeModel populated with my own FileTreeNode objects, which > > extend DefaultMutableTreeNodes. I am adding nodes into the tree by > > doing parentNode.add(subNode), which seems to work just fine in > > most cases. However, in a particular case, my new nodes don't show > > up, even though I can find them both in the children of the parent > > and through the tree model. Right after the add, I call repaint to > > update the tree, and then trace some debug information I get the > > following: > > > > *** This is the first insertion - it works fine *** > > Row for freq [TreeRoot, Smooth Files, AC #377, 20.250] is 21 > > Row for new path [TreeRoot, Smooth Files, AC #377, 20.250, Baseline 1] > > is 22 bounds are java.awt.Rectangle[x=80,y=420,width=82,height=20] > > > > *** This is [...] any consequent insertion - does not work*** > > Row for freq [TreeRoot, Smooth Files, AC #377, 20.250] is 21 > > Row for new path [TreeRoot, Smooth Files, AC #377, 20.250, Baseline 2] > > is -1 bounds are null > > > > It is as if the TreeUI completely loses this node. Furthermore, the > > vertical line preceding the label of 'Baseline 1' disappears after > > 'Baseline 2' is added, but that is the only visible side effect. > > > > So, where has my missing node(s) gone? > > Do you perform the node addition on the event dispatch thread (EDT)? > You ought to. pelakh: Daniele is right. I was looking at the tutorial, and the demos do precisely that in via invokeLater(): <http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html> <http://java.sun.com/docs/books/tutorial/uiswing/examples/zipfiles/compon ents-TreeDemoProject.zip> Looking closer, I see DefaultMutableTreeNode is not thread safe: <http://java.sun.com/javase/6/docs/api/javax/swing/tree/DefaultMutableTre eNode.html> -- John B. Matthews trashgod at gmail dot com home dot woh dot rr dot com slash jbmatthews --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
JTree - subnode not added "pelakh" <pelakh@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
Re: JTree - subnode not a "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
Re: JTree - subnode not a "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
Re: JTree - subnode not a "pelakh" <pelakh@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
csiph-web