日期:2014-05-20 浏览次数:20834 次
Point lastPoint; jlist.addMouseListener(new MouseAdapter(){ @Override public void mouseEntered(MouseEvent e){ lastPoint = e.getPoint(); } }; jlist.addMouseMotionListener(new MouseMotionAdapter(){ @Override public void mouseMoved(MouseEvent e){ int lastIndex = jlist.locationToIndex(lastPoint); Point current = e.getPoint(); int currentIndex = jlist.locationToIndex(current); if (currentIndex == lastIndex) return; ... // highlight lastPoint = current; } };