Difference between Mouse Listener and Action Listener?

前端 未结 3 1301
无人共我
无人共我 2021-02-10 02:05

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

3条回答
  •  自闭症患者
    2021-02-10 02:40

    An ActionListener is used to handle the logical click of a button. A click happens:

    • when the mouse is pressed then released on a button,
    • or when the keyboard shortcut of that button is used,
    • or when the button has the focus and the space bar is pressed,
    • or when the button is the default button and Enter is pressed,
    • or when the button's click() method is called programmatically

    A MouseListener only handles low-level mouse events.

提交回复
热议问题