• Post Reply Bookmark Topic Watch Topic
  • New Topic

getLastSelectedPathComponent returns null  RSS feed

 
Ronen Wolfson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have the following selection listener for a tree:
class GeneralTreeSelection implements javax.swing.event.TreeSelectionListener
{
public void valueChanged(javax.swing.event.TreeSelectionEvent event)
{
Object object = event.getSource();
JTree tree = (JTree)object;
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
if (node==null) return;
treeValueChanged(node);
updateUserActions();
}
}

Every once in a while, when the user right clicks a node
the node is null.
Why does this happen?
How can I mend it?
Thanks
Ronen.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!