This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TreePath exception  RSS feed

 
Muhammad Asghar
Greenhorn
Posts: 6
Firefox Browser Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a GUI in which left side JTree is shown, and the right side a JTable, when the
clicks on the Jtree node, the file, folders in that node(File System nodes) are shown
want when i click on any of the nodes in the JTable, its coresspondance node in the Jtree
be selected.i created TreePath from my selected path, but it gives exception for converting from string to DefaultMutable Tree node

My Code is as under

private void selectNodeActionPerformed(java.awt.event.ActionEvent evt) {
TreePath path= new TreePath("RootNode,MYPC,MYDOCS,Sample Music");
treeMainView.setSelectionPath(path);
System.out.println(path);
}
Exception is under
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to javax.swing.tree.DefaultMutableTreeNode
Please Help
 
Alan Mehio
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is clear. You are trying to cast to String Type even the object you have is a DefaultMutableTreeNode

Can you post the full stack trace as well as the working code so that we can fix it for you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!