简体   繁体   English

在Java应用程序中交换鼠标按钮

[英]Swap mouse buttons in java application

I'm using a dynamic graphic library to display data. 我正在使用动态图形库来显示数据。 By clicking with the left button on a node, a window pops out displaying info about it. 通过在节点上单击鼠标左键,将弹出一个窗口,显示有关该节点的信息。 I would like to use the right button instead, which by now is used to move the node around (without the window popping out). 我想改用右键,此按钮现在用于移动节点(不弹出窗口)。 The problem is: the graph listeners I'm using only respond to the left button. 问题是:我使用的图形侦听器仅响应左按钮。 So the only solution I can think of is to swap the mouse buttons mapping on the java application. 因此,我能想到的唯一解决方案是交换java应用程序上的鼠标按钮映射。 Is there a way to achieve this? 有没有办法做到这一点?

I might be wrong, but can you use MouseListeners for right click, and than use java.awt.Robot to left click that? 我可能是错的,但是您可以使用MouseListeners进行右键单击,而不可以使用java.awt.Robot进行鼠标左键单击吗? just a thought. 只是一个想法。 good luck. 祝好运。

Whoops, sorry. 抱歉,抱歉。 I already solved this a long time ago and I forgot to post the answer: The library I'm using is graphstream, and I just needed to set the graph DefaultMouseManagerm (with overriden functions) which takes care of mouse clicks on the graph. 我很久以前已经解决了这个问题,我忘了发布答案了:我正在使用的库是graphstream,我只需要设置图形DefaultMouseManagerm(带有重写功能)即可处理鼠标在图形上的点击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM