What's the difference between these two events: mouseClicked () and actionPerformed ()? What differs in your execution and when will they run?
What's the difference between these two events: mouseClicked () and actionPerformed ()? What differs in your execution and when will they run?
The event mouseClicked()
is part of MouseListener Interface , "listener" interface for events related to the mouse and controls the events of it. This "listener" is called when the mouse button was clicked (pressed and released) on a component.
The event actionPerformed()
is part of the ActionListener Interface , the "listener" interface of action events and defined actions of a component. This "listener" is usually called when an action occurs.
ActionPerformed will respond when the button is triggered, either by mouse or keyboard, MouseClicked will only notify when the mouse is used.
Source: Difference between MouseClicked and ActionPerformed?