🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

jbcl.control.TreeControl

#9916
From: Hycel
Date: Thu, 06 Jan 2000 00:00
93 lines
3036 bytes
Hello,

Question:

So, does any one no how I can find a node within a TreeControl and then make
it the selected node?

Detail Information:

I am using the com.borland.jbcl.control.TreeControl with a tree structure I
designed myself to store and manipulate data which is then displayed in the
TreeControl.

Example:

public class MyTreeNode implements Serializable
{
  public MyTreeNodeData nodeData;
  public int nodeID;
  public int nodeLevel;
  public int nodeOrder;
  public int  numberOfChildren;
  ...
  public MyTreeNode parentNode;
  public MyTreeNode rightSibling;
  public MyTreeNode leftSibling;
  public MyTreeNode firstChild;
  ...
}

public class MyTree implements Serializable
{
  private MyTreeNode rootNode;
  private MyTreeNode searchNode;
  private MyTreeNode currentNode;
  ....
  public MyTreeNode insertNewNode (MyTreeNode parentNode, MyTreeNode
newNode) {... }
 public void moveSiblingNodeUp(MyTreeNode currentSiblingNode){ ... }
 ...
}

The problem I am having is updating the TreeControl after I have made a
change to MyTree.  In the diagram below I have MyTree containing a root node
'A', with two children, 'AA' and 'AB'.   The TreeControl display's the same
thing.

A -
     AA -
              AAA
              AAB
     AB -
             ABA
             ABB

With the cursor on AB as the selected Item I call MyTree.moveSiblingNudeUp.

void moveUpButtonControl_action Performed (ActionEvent e)
{
  MyTreeNode currentNode;

  GraphLocation[] selectedLocations = treeControl.getSelection().getAll();
  if (selectedLocations.length > 0)
    {
      currentNode = (CodeTrackerTreeNode)
treeControl.get(selectedLocations[0]);
      if (currentNode.nodeOrder > 1)
        {
           DmgphTree.moveSiblingUp(currentNode);
           ...
        }
}

Now that the two siblings, 'AA' and 'AB' have been switched, I would like to
update the TreeControl so that is shows this result and have the cursor
still siting on sibling, 'AB' as the selected node in the TreeControl.

I have tried using the methods expandAll and find in the following command
to no avail.

treeControl.expandAll(treeControl.find(currentNode.nodeData));

Currently, the only thing I can do is reload MyTree into the TreeControl and
then manually select the node I want to get to.

So, does any one no how I can find a node within a TreeControl and then make
it the selected node?

Thank you to any one who can help,

Hycel
hycel@mediaone.net
hycel@email.msn.com
Technical Details
Message-ID: <852590$q6i2@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,83ae6506ed959249,start
X-Google-Attributes: gid111d45,public
From: "Hycel" <hycel@mediaone.net>
Subject: jbcl.control.TreeControl
Date: 2000/01/06
Message-ID: <852590$q6i2@bornews.borland.com>
X-Deja-AN: 569084509
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing