java - 有没有办法为添加了鼠标适配器的东西设置操作命令?

标签 java mouseevent actionlistener mouseclick-event

如果我有 5 个具有相同鼠标适配器的 JPanel,并且我想确定单击了哪个面板,我该怎么做?

最佳答案

MouseEventComponentEvent 的子类,因此:

http://download.oracle.com/javase/6/docs/api/java/awt/event/ComponentEvent.html#getComponent%28%29

getComponent

public Component getComponent()

Returns the originator of the event.

Returns: the Component object that originated the event, or null if the object is not a Component.

关于java - 有没有办法为添加了鼠标适配器的东西设置操作命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5861589/

相关文章:

java - 如何使用Java获取YouTube下载链接?

Java 正则表达式去除 XML 标签,但不去除标签内容

Java机器人点击侧面按钮

java - JFrame 总是为 Action 监听器内的变量输出 null

java - 使用actionlistener调用同一个类中的void函数

java - 调试器未在断点 : Websphere in Eclipse 处停止

Java 8 减去日期返回 1 天

python - 鼠标单击并在python中拖动

c++ - 如何处理鼠标右键单击 QSystemTrayIcon?

java - 如何监听其组件之一的JButton?