For example:
public void mouseReleased(MouseEvent e)
{
int currentX, currentY;
currentX = e.getX();
currentY = e.getY();
// if rightmouse
if(SwingUtilities.isRightMouseButton(e))
{
// your code...
}
else if( if(SwingUtilities.isLeftMouseButton(e))
{
//your code...
}
}