Two Laptop Bag
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TreeSelectionListener interface valueChanged()" Watch "TreeSelectionListener interface valueChanged()" New topic

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)

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

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:
subject: TreeSelectionListener interface valueChanged()
It's not a secret anymore!