区分不同的鼠标按钮,可将getModifiers的返回值同BUTTON1_MASK,BUTTON2_MASK和BUTTON3_MASK的值进行对比。windows操作系统中,BUTTON3_MASK为右键。
if((evt.getModifiers()&InputEvent.BUTTON3_MASK)!=0)
//用于右键单击代码。
以上摘自Core Java2第一卷
if((evt.getModifiers()&InputEvent.BUTTON3_MASK)!=0)
//用于右键单击代码。
以上摘自Core Java2第一卷
Returns the number of mouse clicks associated with this event.
还是看看这个类吧,
javax.swing.Class SwingUtilities这个类就有鼠标左右键点击,很简单。public static boolean isRightMouseButton(MouseEvent anEvent)。