This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: TreeSelectionListener interface valueChanged()
 
Similar Threads
Tree and drawing within the same panel
Dynamic JTree Components
How do I know which object is selected?
Design question.
JtreeTable does not return complete selection path