pro_java thread: Crazy!! Tree object Casting... Error
I've created a Jtree, consisting of objects of type (String x, String y,
String z), When i rename a leaf id like the first String "x" in the object
to change accordingly and the rest to remain the same...
I've used a TreeModelListener with the treeNodesChanged methods to listen
for a rename and the below code to change it, But i keep getting the
following:-
java.lang.ClassCastException: java.lang.String
// Code
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
MObject obj = (MObject) node.getUserObject(); //error
node.setUserObject(new MObject (obj.x, obj.y, obj.z));
the casting works perfectly in other sections of the code just not here.
please help Thx