Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Mouse Listener and Action Listener?

Whats the difference? When would you use a mouse listener? or a action listener? Please and Thank You!

like image 998
Marcella Ruiz Avatar asked Sep 04 '15 13:09

Marcella Ruiz


1 Answers

The first difference is that A MouseEvent is a true system event, whereas an ActionEvent is a synthesized event... It is triggered by a system event.

MouseListener (and MouseMotionLister, MouseWheelListener) are useful when (a) you are interested in the event details (ie x/y click spot) or when the component you are using doesn't support ActionListeners

Actions are good when you have a task that can executed without external event details (like exiting the program) and that you'd like to be able to access either in more than one component, or to set off / start with either the keyboard or the mouse

like image 103
ControlAltDel Avatar answered Sep 29 '22 20:09

ControlAltDel