简体   繁体   English

摆动:仅在ImageIcon而不是JLabel上使用MouseListener

[英]Swing: MouseListener only on ImageIcon not JLabel

I have a Java Swing application with a JFrame containing a JLabel containing an ImageIcon . 我有一个带有JFrame的Java Swing应用程序,其中的JFrame包含一个包含ImageIconJLabel I want to monitor the mouse entering/exiting the ImageIcon . 我想监视进入/退出ImageIcon的鼠标。

For now I use the addMouseListener method of JLabel but the event Entered & Exited are thrown only when I enter/exit the application's window, not the ImageIcon . 现在,我使用JLabeladdMouseListener方法,但是仅当我进入/退出应用程序的窗口时才抛出Enter和Exited事件,而不是ImageIcon

I see no addMouseListener method for ImageIcon . 我看不到ImageIcon addMouseListener方法。

How can I do this? 我怎样才能做到这一点?

I have a Java Swing application with a JFrame containing a JLabel containing an ImageIcon. 我有一个带有JFrame的Java Swing应用程序,该JFrame包含一个包含ImageIcon的JLabel。 I want to monitor the mouse entering/exiting the ImageIcon. 我想监视鼠标进入/退出ImageIcon。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM