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


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

Re: how to have empty nod

From "Edwin Dankert" <edwin.dankert@THRWHITE.remove-dii-this>
Subject Re: how to have empty nod
Message-ID <1170346080.802858.23560@p10g2000cwp.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <45c202a1$0$18914$4c368faf@roadrunner.com>
Date 2011-04-27 15:30 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
> 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
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.

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