【问题标题】:How to assign the event which triggers Action Listener?如何分配触发 Action Listener 的事件?
【发布时间】:2016-12-03 08:05:55
【问题描述】:

Picture of some of the code that I'm trying to work with

我正在尝试用 Java 制作它,以便我的标签可以更改它们显示的图标,并且看起来 ActionListener 是最好的方法,但我仍然有点困惑。

显然 ActionListener 将在事件发生时触发并执行 thehandler 类(根据我找到的教程),但我如何声明触发 ActionListener 的事件将是什么?还有为什么我是红衣呢?

感谢您的帮助。

【问题讨论】:

标签: java graphics jframe actionlistener


【解决方案1】:

您应该尝试实现 MouseListener 而不是更通用的 ActionListener 接口。这会让你听到鼠标点击等。

Difference between Mouse Listener and Action Listener?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 2021-11-24
    相关资源
    最近更新 更多