Jtree - node from path question

Discussion in 'Java' started by Tim, Feb 16, 2004.

  1. Tim

    Tim Guest

    Hi

    I extended the defaultrTreeModel and used my own objects as nodes in
    the tree -
    the problem I have now that I want to retrofit my tree with dynamic
    addition of nodes is that is that when I call
    myTreePath.getLastPathComponent() I get my own object back and not a
    reference to a node (which I want so I can add a node to it)

    i cant find a way of getting the node from a treepath !!

    Please help !!

    Tim
    Tim, Feb 16, 2004
    #1
    1. Advertising

  2. Tim

    xarax Guest

    "Tim" <> wrote in message
    news:...
    > Hi
    >
    > I extended the defaultrTreeModel and used my own objects as nodes in
    > the tree -
    > the problem I have now that I want to retrofit my tree with dynamic
    > addition of nodes is that is that when I call
    > myTreePath.getLastPathComponent() I get my own object back and not a
    > reference to a node (which I want so I can add a node to it)
    >
    > i cant find a way of getting the node from a treepath !!
    >
    > Please help !!
    >
    > Tim


    You wrote that your own objects are the nodes, so you
    *are* getting the node. If you need something else
    that represents a "node", then make that thing a field
    in your object. When you get your object, look at the
    field in your object for the "node" thing.
    xarax, Feb 16, 2004
    #2
    1. Advertising

  3. Tim

    Tim Guest

    Are you saying that if I use my own object then there is no
    DefaultMutableTreeNode at that point in the tree - only my object ???
    I think I see a light bulb !! But how do you add other objects as
    children to my object ??

    Thanks
    Tim





    "xarax" <> wrote in message news:<Kc5Yb.5951$>...
    > "Tim" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I extended the defaultrTreeModel and used my own objects as nodes in
    > > the tree -
    > > the problem I have now that I want to retrofit my tree with dynamic
    > > addition of nodes is that is that when I call
    > > myTreePath.getLastPathComponent() I get my own object back and not a
    > > reference to a node (which I want so I can add a node to it)
    > >
    > > i cant find a way of getting the node from a treepath !!
    > >
    > > Please help !!
    > >
    > > Tim

    >
    > You wrote that your own objects are the nodes, so you
    > *are* getting the node. If you need something else
    > that represents a "node", then make that thing a field
    > in your object. When you get your object, look at the
    > field in your object for the "node" thing.
    Tim, Feb 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,375
  2. Replies:
    0
    Views:
    633
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,393
    Dimitre Novatchev
    Aug 24, 2006
  4. jumpz
    Replies:
    3
    Views:
    606
    Jean-Baptiste Nizet
    Nov 12, 2007
  5. Peter Mueller
    Replies:
    6
    Views:
    4,513
    Stefan Ram
    Jan 13, 2008
Loading...

Share This Page