Skip to main content

JXTreeTable view updates on model change

6 replies [Last post]
cdrichmond
Offline
Joined: 2008-08-14

When I add nodes to a node in my JXTreeTable, they do not show up in the view.

They show up if I add them programatically before I expand that node for the first time in the UI, but if I have expanded it at all before I add them, then they will never show up even if I collapse that node and re-expand it.

Does anyone know why or what I must do to fix that?

Thanks,

Chris

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kschaefe
Offline
Joined: 2006-06-08

Chris,

> Does anyone know why or what I must do to fix that?

Not without a code sample. Please provide a small, runnable demo showing the problem.

Karl

cdrichmond
Offline
Joined: 2008-08-14

On a related note, I am adding these items programmatically by drag and drop from another control in the GUI. That all works fine, but I can't seem to find the actual Node locaion where I am currently dropping. Right now I have a hardcoded getChildAt(0).getChildAt(0) type of workaround, but I would really like to be able to discover dynamically where I am dropping.

I am using:

JXTreeTable.DropLocation dl = (JXTreeTable.DropLocation)info.getDropLocation();

int row = dl.getRow();

TreePath currentPath = treeTable.getPathForRow(row);

which seems to be on the right path, but I just can't seem to locate the right combo of method calls to get me the node I have dropped on instead of just the row....

kschaefe
Offline
Joined: 2006-06-08

currentPath.getLastComponent()

Karl

cdrichmond
Offline
Joined: 2008-08-14

ok..this seems to work

treeTableModel.insertNodeInto(node, parentNode, parentNode.getChildCount());

to just insert at the last spot on the parent node's child nodes

but parentNode is something I created by hardcoding a node location

parentNode = (MyMutableTreeTableNode)rootNode.getChildAt(0);

I would like to create parentNode dynamically...so how do I get from

currntPath.getLastComponent()

to creating parentNode...I cannot seem to figure out this code linkage...

and .insertNodeInto fixes that refres problem I was having earlier as a side note.
Thanks,

Chris

kschaefe
Offline
Joined: 2006-06-08

Please reread the TreePath documentation.

You can inspect the TreePath in any variety of ways. All of the information you need about the current node and it's parent is available from it.

If you're using TreeTableNode, you should not that the node has a getParent method.

Karl

cdrichmond
Offline
Joined: 2008-08-14

link to documentation? I get alot of dead links on the Swinglabs swingx page...including documentation..