如何在 Swing 应用程序中使用后退和前进鼠标按钮?
问题很简单。我找不到很多关于这个问题的链接,而且我找到的链接似乎并没有回避真正的问题。我的应用程序必须处理后退和前进鼠标按钮的鼠标按下/释放事件。我该如何处理这个问题?
编辑:这是使用JDK 1.6。
The question is pretty simple. I couldn't find many links regarding this issue, and the ones I found didn't seemed to avoid the real question. My application must handle the mouse pressed/released events for the back and forward mouse buttons. How can I handle this?
EDIT: This is using JDK 1.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过调用检查是否检测到其他鼠标按钮:
MouseInfo.getNumberOfButtons();
检查当您单击这些附加按钮时是否会触发 MouseEvents。如果是这样,
MouseInfo.html 是什么意思? getButton()
返回?根据 MouseInfo.getButton() 的 javadocs :
Check if additional mouse buttons are detected by calling:
MouseInfo.getNumberOfButtons();
Check if MouseEvents are fired when you click those additional buttons. If so, what does
MouseInfo.getButton()
return?According to the javadocs for MouseInfo.getButton():
看一下 MouseEvent .getButton() 和 Toolkit.areExtraMouseButtonsEnabled() 。
Have a look at MouseEvent.getButton() and Toolkit.areExtraMouseButtonsEnabled().
功劳属于原始响应者,只需添加一个用于全局后退/前进按钮检测的现成代码示例,以防对其他人有帮助(JDK 1.8)
Credit belongs to the original responders, just adding a ready-to-use code sample for global back-/forward-button detection in case it helps anyone else (JDK 1.8)
我不使用 JDK7,也从未听说过后退/前进按钮。不过我确实知道
SwingUtilities
类有方法:如果现在支持后退/前进,那么我猜他们已经添加了:
I don't use JDK7 and have never heard of back/forward buttons. However I do know that the
SwingUtilities
class has methods:If back/forward are now supported then I would guess they have added: