my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes TreeSelectionListener interface valueChanged() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TreeSelectionListener interface valueChanged()" Watch "TreeSelectionListener interface valueChanged()" New topic
Author

TreeSelectionListener interface valueChanged()

Nageswar Kakolla
Ranch Hand

Joined: Jan 16, 2006
Posts: 71
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

Joined: Jan 20, 2006
Posts: 150
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 ..


~ Anand,
SCJP 1.5, SCWCD 1.5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TreeSelectionListener interface valueChanged()