What is better to use: Action vs ActionListener?

前端 未结 1 1726
花落未央
花落未央 2020-12-17 23:42

Myself, I always use ActionListener as swing event-handler (e.g. button-click), and it is the most common listener I\'ve seen in most swing applications.

However, So

相关标签:
1条回答
  • 2020-12-17 23:58

    An Action is preferred if you need to share functionality across components. From the docs

    if you have two or more components that perform the same function, consider using an Action object to implement the function.

    but also says

    An Action object is an action listener that provides not only action-event handling, but also centralized handling of the state of action-event-firing components such as tool bar buttons, menu items, common buttons, and text fields. The state that an action can handle includes text, icon, mnemonic, enabled, and selected status.

    0 讨论(0)
提交回复
热议问题