[英]Right click mouse event
I search through this forum but I can't find a good explanation on this topic. 我搜索这个论坛,但我找不到关于这个主题的好解释。 Is there any different from the below statements?
以下陈述有什么不同吗? Which way is the better way to trigger this event?
哪种方式是触发此事件的更好方法?
if (evt.getButton() == 3)
Vs. 比。
if (SwingUtilities.isRightMouseButton(evt))
SwingUtilities.isRightMouseButton(evt) SwingUtilities.isRightMouseButton(EVT)
this uses a bit operand to compare: 这使用比特操作数进行比较:
(evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
while other, just compare with a magic number that can change, I would rather change first comparison to: 而其他,只是与可以改变的幻数比较,我宁愿改变第一个比较:
if(evt.getButton() == java.awt.event.MouseEvent.BUTTON3)
SwingUtilities is part of the javax which comes with jdk, so I would prefer to delegate that responsabillity to this utility (helper) class, so in that case, SwingUtilities wins. SwingUtilities是jdk附带的jdk的一部分,因此我更愿意将该责任委托给此实用程序(帮助程序)类,因此在这种情况下, SwingUtilities会获胜。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.