[英]Java alternatives to AWT to capture mouse events?
是否有AWT的替代方法可以在Java中获取鼠标按下事件?
Mouse event implies there's a window / frame on which the event occurred. 鼠标事件表示事件发生在一个窗口/框架上。 Typically each GUI toolkit comes with its own list of event listeners / dispatchers.
通常,每个GUI工具箱都带有自己的事件侦听器/调度程序列表。 So the question should really be: "What are the alternatives to AWT?"
因此,问题实际上应该是: “ AWT的替代品有哪些?”
Finally, you might also want to check out SWT (the GUI toolkit used for Eclipse, and an alternative to both AWT and Swing), which is somewhat of a return to the AWT idea of accessing native Widgets through Java.
最后,您可能还想看看SWT(用于Eclipse的GUI工具包,是AWT和Swing的替代品),这有点像是通过Java访问AWT的想法的AWT理念的回归。
If we are talking about specific frameworks then (as far as I know they still use AWT event system underneath): 如果我们在谈论特定的框架,那么(据我所知,它们仍然在下面使用AWT事件系统):
JMonkey game engine. JMonkey游戏引擎。 Official Page
官方网站
LWJGL . LWJGL 。 Light weight java gaming library.
轻量级Java游戏库。 Official Page
官方网站
There are probably other frameworks but it seems the core functionality comes from AWT to handle native mouse query. 可能还有其他框架,但似乎核心功能来自AWT来处理本机鼠标查询。
Since I found lots of unanswered threads on this I'll share the solution. 由于我发现了许多未解决的问题,因此我将分享解决方案。 Turns out Windows 7 defaults Java to wm_gesture rather than wm_touch events so AWT does not get press events as expected.
事实证明,Windows 7默认将Java设置为wm_gesture而不是wm_touch事件,因此AWT无法获得预期的新闻事件。 What you need to do is use JNA to register the window as a touch window ( https://msdn.microsoft.com/en-us/library/windows/desktop/dd317326(v=vs.85).aspx ).
您需要做的是使用JNA将窗口注册为触摸窗口( https://msdn.microsoft.com/zh-cn/library/windows/desktop/dd317326(v=vs.85).aspx )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.