Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

TreePath exception

Posts: 6
MyEclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
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
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic