A "delete selected nodes" button invokes the following code when pressed:
DefaultTreeModel model = (DefaultTreeModel ) my_tree.getModel() ;
TreePath  tps = my_tree.getSelectionPaths() ;
for ( int i=0; i<tps.length; i++ )
MutableTreeNode node = (MutableTreeNode ) tps[i].getLastPathComponent() ;
model.removeNodeFromParent( node ) ;
However, I get a ClassCastException on this line:
DefaultTreeModel model = (DefaultTreeModel ) getModel() ;
Why is this?
Could it be anything to do with the fact that I'm assigning a custom TreeModel when I instantiate my JTree ?