Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TreeSelectionListener interface valueChanged()

 
Nageswar Kakolla
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created JTree and implemented TreeSelectionListener interface and hence
i public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
}

what is the purpose of valueChanged ?
I know we have to implement valuechanged whenever Tree selection event is generated to be notified , what needs to be done in valueChanged method.

I am getting error when I select leaf node as ClassCastException in my code ?
 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

purpose of valueChanged method is --

- if u want to know which node is selected
- if u want enable/disable other components depeding on node selection in tree

I have used selection listener in my application for above purpose ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic