javaswingredrawswingxjxtreetable

Updating JxTreeTable when model changes


I'm having trouble working out the best way to repaint a JxTreeTable when the underlying model changes.

For each node in the table I have a corresponding model object, so if a model changes I can get the Node.

Thereafter, given a Node, how do you trigger a redraw/change event on the table to force it to redraw. Clues welcome, apologies for being light on details, I don't have a much to show by way of code.


Solution

  • I ended up doing this:

                TreeTableNode parent = node.getParent();
                modelSupport.firePathChanged(new TreePath(getPathToRoot(parent)));
    

    The code is called in my model, which extends, DefaultTreeTableModel.

    node is the AbstractMutableTreeTableNode that contains the model that changed.