level 11
JPanel实现mouseEntered方法,JPanel中还有若干个JButton,鼠标进入到JButton时,JPanel就发生了mouseExited事件,这个让我很头痛,有好的解决方法么?
我的想法是即使鼠标进入了JButton后,JPanel也不发生mouseExited,有好办法么?
2013年07月10日 03点07分
1
level 12
可以用下面的方法简单检查 mouseExit 被调用时鼠标是不是还在控件范围内:
private boolean isCursorInBounds(MouseEvent e) {
Rectangle r = ((Component)e.getSource()).getBounds();
r.x = r.y = 0;
return r.contains(e.getPoint());
}
2013年07月10日 03点07分
2
mouseExited*
2013年07月10日 03点07分
回复 那十无忧 :类似的方法我试过,可以让离开问题不乱报,可是真的发生鼠标离开事件,却不能很好的判断,我再试试你的方法,谢谢
2013年07月10日 04点07分