2009-11-25 4 views

답변

5

네, 맞습니다. mouseMotionListener는 위에 마우스 이동은 "핫스팟"때 작업을 수행하는 데 사용됩니다

좋은 예는 당신이 동안을 수행 할 수있는 많은 이벤트를 추가하고 싶어하지 않는 here

mousePressed 이벤트 처리, 당신은 단지 mousePressed 이벤트를 필요로 찾을 수 있습니다 마우스가 맴돌다.

4

그들은 다른 이벤트를 수신 :

MouseListener

mouseClicked(MouseEvent event) // Called just after the user clicks the listened-to component. 
mouseEntered(MouseEvent event) // Called just after the cursor enters the bounds of the listened-to component. 
mouseExited(MouseEvent event) // Called just after the cursor exits the bounds of the listened-to component. 
mousePressed(MouseEvent event) // Called just after the user presses a mouse button while the cursor is over the listened-to component. 
mouseReleased(MouseEvent event) // Called just after the user releases a mouse button after a mouse press over the listened-to component 

MouseMotionListener

mouseDragged(MouseEvent event) // Called in response to the user moving the mouse while holding a mouse button down. This event is fired by the component that fired the most recent mouse-pressed event, even if the cursor is no longer over that component. 
mouseMoved(MouseEvent event)  // Called in response to the user moving the mouse with no mouse buttons pressed. This event is fired by the component that's currently under the cursor. 

가 필요하시면 이벤트에 따라 청취자를 추가합니다.

관련 문제