Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #869

Re: how to have empty nod

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Subject Re: how to have empty nod
Message-ID <45c2792b$0$28092$4c368faf@roadrunner.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1170346080.802858.23560@p10g2000cwp.googlegroups.com>
References <1170346080.802858.23560@p10g2000cwp.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 40
Date Wed, 27 Apr 2011 15:30:01 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918201 96.60.20.240 (Wed, 27 Apr 2011 10:30:01 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:30:01 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:869

Show key headers only | View raw


  To: comp.lang.java.gui
Edwin Dankert wrote:
>> Well since I'm only grabbing a node's children when the node is selected
>> or expanded the JTree probably is using the isLeaf method from the
>> TreeModel to not draw an expansion control next to the node because at
>> that point until the node's children are retrieved it is a leaf node
>> which is why I have to put in a fake node so that it isn't a leaf node
>> any longer. Then I have to go to the trouble of deleting the node and
>> still make the application behave properly. Deleting it is easy but in
>> my OP I stated the trouble I ran into when I attempted that.
> 
> Sun, has provided all the functionality to implement this relatively
> simply, I think however that the route you have chosen might not be
> the most effective one.
> 
> Most Swing components are controlled by their models so, I would
> suggest you try and implement the TreeModel or implement the TreeNode
> (which is often the easier route) or a combination of both, this would

My custom node already extends DefaultMutableTreeNode and I'm using the 
DefaultTreeModel for the tree itself.

> allow you to return false for the isLeaf() method. I would also
> recommend to implement a TreeWillExpandListener to perform the look-up
> of the child TreeNodes before the tree is expanded.

I'll try that since Rogan also suggested that. Hopefully that will solve 
the problem.

> 
> Regards,
> Edwin
> --
> http://www.edankert.com/
>

---
 * 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 | NextPrevious in thread | Next in thread | Find similar


Thread

how to have empty nodes i "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
  Re: how to have empty nod "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
    Re: how to have empty nod "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
      Re: how to have empty nod "Edwin Dankert" <edwin.dankert@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
        Re: how to have empty nod "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
    Re: how to have empty nod "Rogan Dawes" <rogan.dawes@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000

csiph-web