java - 获取组件外部的鼠标事件
我和这里的人有同样的问题这里,因为我需要在 OS X 上拖动框架时跟踪框架位置。问题尚未解决,因此:
我如何告诉框架鼠标按下事件发生在其(操作系统本机)标题栏上,或者更一般地说,鼠标按下事件发生在屏幕上的某个地方?
i'm having the same issue as the person here, in that i need to track a frame location while it is being dragged on OS X. The question had not been resolved there, so:
how do i tell a frame that a mouse down event happened on its (OS-native) title bar or, more generally, that a mouse down event happened somewhere on the screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从java 1.5开始
编辑:
本机键盘鼠标挂钩
http://www.jotschi.de/?p=90
Since java 1.5
EDIT:
Native keyboard mouse hook
http://www.jotschi.de/?p=90
使用纯 Java,您永远无法判断鼠标按下事件发生在其(操作系统本机)标题栏上,或者在这种情况下发生在应用程序窗口之外的任何事件(不包括标题栏)。
重要的是要了解,作为 AWT/Swing 中的程序员,您的上下文、领域和权力仅位于应用程序窗口内。
最好的办法是使用 JNI。
Using pure Java, you can never tell that a mouse down event happened on its (OS-native) title bar, or for that case any event outside you application window(excluding title bars).
It's important understand that as a programmer in AWT/Swing your context and realm and power lies only within the application window.
Best shot is to use JNI.