I am trying to figure out how to code a event that, if clicked in a Swing JTree and the mouse does not click anything in the tree, to get a println that says "nothing".
Say I have a tree 'info_tree' with an AWT.event.Mouwesvent as such:
private void info_treeMouseClicked(java.awt.event.MouseEvent evt) {
if(info_tree.getSelectionPath() /*something along the lines of is empty or if !info_tree.getSelectionPath().isEmpty()*/
){system.out.println("Nothing");
}else{
system.out.println("Something");
}
}
I can't find anything to compare a selectedPath or element of a tree.
You may wish to try
If (info_tree.getSelectionPath()==null)
But,then you may want to switch your output lines around. Because that as-is is a true/false condition. If false it'll goto else. That could solve it as well.