Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "John B. Matthews" Subject: Re: JTree - subnode not a Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 55 Date: Wed, 27 Apr 2011 15:47:59 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303919279 96.60.20.240 (Wed, 27 Apr 2011 10:47:59 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:47:59 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3970 To: comp.lang.java.gui In article , Daniele Futtorovic 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(): Looking closer, I see DefaultMutableTreeNode is not thread safe: -- 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