[英]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
包含一个包含ImageIcon
的JLabel
。 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
. 现在,我使用
JLabel
的addMouseListener
方法,但是仅当我进入/退出应用程序的窗口时才抛出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。
agreed, in Icon / ImageIcon isn't implemented any mouse or key event 同意,在Icon / ImageIcon中未实现任何鼠标或按键事件
best of options is to use un_decorated JButton 最好的选择是使用un_decorated JButton
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.