Updating of a Tree when the label changes
From: Deborah K. Charan (dcharan_at_atcorp.com)
Date: 10/28/04
- Next message: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Previous message: Maik Heller: "JMenuItem with checkbox - on mac"
- Next in thread: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Reply: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Oct 2004 06:11:42 -0700
I have seen postings about similar problems, and have tried
duplicating what others have tried, but my tree never updates with the
new values. In the code below, I have stepped through and see the new
nodes with the correct values, but it never redraws. The reason that
I am removing and reinserting the node is that just calling
node.setUserObject(newVal) does not change the length of the label.
Atleast it updates the label to ... :)
Here is the code snipet. If I don't actually expand the tree until
later in the game, I do get the current value for SysUpTime and
numPktsRecvd, but it never updates it from there.
if (label == "SysUpTime")
node = _sysUpTime;
else if (label == "Packets Received")
node = _numPktsRecvd;
DefaultMutableTreeNode newNode;
TreeNode parent = node.getParent();
int index = parent.getIndex(node);
_localModel.removeNodeFromParent(node);
newNode = new DefaultMutableTreeNode(
new String(label + ": " + value), false);
_localModel.insertNodeInto((MutableTreeNode) newNode,
(MutableTreeNode) parent, index);
if (label == "SysUpTime")
_sysUpTime = newNode;
else if (label == "Packets Received")
_numPktsRecvd = newNode;
_localModel.reload();
Any information would be appreciated.
Thanks
Debbie Charan
- Next message: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Previous message: Maik Heller: "JMenuItem with checkbox - on mac"
- Next in thread: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Reply: Babu Kalakrishnan: "Re: Updating of a Tree when the label changes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|