1

java tree.addMouseMotionListener();鼠标监听功能

 tree.addMouseMotionListener(new  MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent arg0) {
                //鼠标移动
                int x = (int) arg0.getPoint().getX();
                int y = (int) arg0.getPoint().getY();
                System.out.println("x = " + x +", y = " + y);
                TreePath path = tree.getPathForLocation(x, y);
                System.out.println("PathForLocation: " + tree.getPathForLocation(x, y));
                tree.getComponentAt(x, y).repaint();
                LeftTreeICON.mouseRow = tree.getRowForLocation(x, y);
                int rowforlocation = LeftTreeICON.mouseRow;
                System.out.println("RowForLocation: " + tree.getRowForLocation(x, y));
                tree.repaint(); 

//              CLog.d("UIDevices: mouseMoved row=" + LeftTreeICON.mouseRow + 
//                      "   x=" + x + "  y=" + y);

            }
        });

如何让鼠标只在点击tree节点时才触发动作,现在在点击空白处也会触发tree.getLastSelectedPathComponent()的任务

查看全部
victorsusprd
Snail-Win
2015/08/11 08:22
  • 移动
  • java
  • 鼠标
  • 点赞
  • 收藏
  • 回答
    私信

0个回复