e.getSource()==tree
这个方法e.getSource()返回的时Object
你需要把他转换成JTree型的
(((JTree)e.getSource()) == tree)
这样应该没有问题了吧