dcsimg

How can I detect a right click of a mouse?

Sandip Chitale


public void mouseClicked(MouseEvent me)
{
  if (me.getModifiers() & BUTTON3_MASK != 0)
  {
     // it is right mouse click
     // it assumes 123 mouse settings
  }
}

If you want to really show the popup menu in response to right mouse click you should call use


mouseEvent.isPopupTrigger()

from both mousePressed and mouseReleased to be truly platform independant.