How do I double-click a JTree node and get its name?
If I call evt.getSource() it seems that the object returned is a JTree. I can’t cast it to a DefaultMutableTreeNode.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the Java Docs
To get the nodes from the
TreePathyou can walk the path or simply, in your case, useTreePath#getLastPathComponent.This returns an
Object, so you will need to cast back to the required node type yourself.