JFrame上的MouseListener [英] MouseListener on JFrame
本文介绍了JFrame上的MouseListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的JFrame上收到鼠标事件(特别是鼠标输入和退出事件)的通知。但是当我添加一个mouselistener时,我可以在框架的边框上获取事件,而不是整个框架的内容。
I want to be notified of mouse events (specifically the mouse entered and exited events) on my JFrame. But when i add a mouselistener to it i get the events on the borders of the frame not the entire frame with it's contents.
任何想法,为什么?
编辑:或至少你有另一种选择?我想要一个gloabal的方式来捕捉JFrame上的鼠标事件。也许一个mouselistener不是答案。
EDIT : Or at least do you have an alternative? I want a "gloabal" way to catch mouse events on the JFrame. Maybe a mouselistener is not the answer.
推荐答案
你可以获取所有的事件,并检查他们的源是一个组件在JFrame中。
You can get all events and check if their source is a component in the JFrame.
请参阅 Toolkit.addAWTEventListener
这篇关于JFrame上的MouseListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文