mouseeventmouselistenerjava

difference between mouseReleased and mouseClicked


searching on the JAVA api document, i knew the difference between the mousePressed and mouseClicked. but.. the mouseClicked method involves both pressing and releasing so the action is done after the releasing the mouse, i don't find much difference with mouseReleased.

when i tried myself, i found that pressed and clicked are different because the time of action is different, but it's not the case between clicked and released.

my program is about drawing oval at the selected point in canvas

i'm looking for help in this problem.


Solution

  • There is not a very big difference, but mouseClicked happens when:

    Invoked when the mouse button has been clicked (pressed and released) on a component.

    Instead mouseReleased:

    Invoked when a mouse button has been released on a component.

    So if you click outside your application, drag the mouse on the application and release it you have a mouseReleased event, but you don't have a mouseClicked event, because it was pressed outside the application.