只能找到点选了那一项,不能实现你的变色:class MyMouseAdapter extends MouseAdapter
{
public void mousePressed(MouseEvent e) 
    {
     JTree tree =(JTree)e.getSource();
     int clickrow = tree.getRowForLocation(e.getX(),e.getY());
     if(clickrow != -1)
     {
     TreePath treepath = tree.getPathForRow(clickrow);
     TreeNode treenode = (TreeNode)treepath.getLastPathComponent();
     System.out.println (treenode.toString());
     }
    }
}

解决方案 »

  1.   

    要让节点变色需要用到DefaultTreeCellRenderer,可以自己写一个类MyTreeCellRenderer继承DefaultTreeCellRenderer,然后在方法里调用setBackgroundSelectionColor(your color)即可,光用鼠标监听是不够的!
      

  2.   

    就像windows一样,我们右键点中某个文件后,该文件就变色以及出现了对话框