I have a set of nodes for a command-line application and would like to put a GUI over it. I want to display the tree visually and am using a JTree
. I have written my own tree model that implements the TreeModel
interface and the tree is rendered as expected.
But now I want to be able to insert or remove nodes. Currently I am just redrawing the tree whenever I perform an insert or remove operation, which is a terrible solution especially if there are thousands of nodes.
The DefaultTreeModel
handles all of the inserting and removing and tree updating as required. I would have to figure out how that works for my own model.
The sole reason for using a custom tree model is just so that I can work with the existing nodes objects. Is this reason "good enough" to implement a custom model or should I look for a way to use the default mutable tree node objects?