First, it is important to be precise to avoid confusion. An "event is not assigned" to a component, it is assigned a listener that the component accepts. The listener will have several methods defined that the component will invoke when it needs to notify an event.
mouseClicked()
is a method of MouseListener
, actionPerformed()
is a method of ActionListener
. The two classes have different functions; MouseListener
deals with low level events (what is done with the mouse), the events of ActionListener
are more at high level. For example, when you click on a button, the method mouseClicked
of the MouseListener
associated% will be invoked, and the method actionPerformed()
of the ActionListener
. But if you navigate with the tab and on the button press Enter, it will not call mouseClicked()
but yes% actionPerformed()
.
What happens if a component does not have assigned listeners ? It will not call any method when it detects the event, no logic will be executed.