🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9113

Re: Deleting node from JTree

#9113
From: Sven Goetgeluck
Date: Fri, 26 May 2000 00:00
41 lines
1595 bytes
hi jack this is the code i use in my tree

  public void removeCurrentNode()
    {
     TreePath currentSelection = tree.getSelectionPath();
     if (currentSelection != null)
     {
       DefaultMutableTreeNode currentNode =
(DefaultMutableTreeNode)(currentSelection.getLastPathComponent());
       MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());

        if (parent != null)
        {
          if (currentNode.isLeaf()==true)
          {
          curselnode = (DefaultMutableTreeNode)parent;
           treeModel.removeNodeFromParent(currentNode);
           return;
           }
        }
      }
     }
hope this will help

greetings

Jack Cook <jcook@shellus.com> schreef in berichtnieuws 392d534f@dnews...
> All,
>
> I am trying to delete a node from JTree using the DefaultMutabableTreeNode
> removeFromParent method. Whenever I remove the node it still remains in
the
> display of the tree. I am doing a  revalidate() and repaint() but nothing
> seems to
> work. What am I doing wrong?
>
> Thanks,
>
> Jack
>
>
Technical Details
Message-ID: <392d7915@dnews>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <392d534f@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c207b5509b57b5e5
X-Google-Attributes: gid111d45,public
From: "Sven Goetgeluck" <sven.goetgeluck@pandora.be>
Subject: Re: Deleting node from JTree
Date: 2000/05/26
Message-ID: <392d7915@dnews>
X-Deja-AN: 627287283
References: <392d534f@dnews>
X-Trace: 25 May 2000 12:03:49 -0800, 127.0.0.1
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: borland.public.jbuilder.java.swing
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200