Java tutorial
//package com.java2s; import java.awt.event.MouseEvent; import javax.swing.*; public class Main { /** If you use command-click (on a one-button mouse) to simulate right-click, java.swing.SwingUtilities.isLeftMouseButton returns true (and so does java.swing.SwingUtilities.isRightMouseButton), which results in the wrong behavior. */ public static boolean isLeftMouseButton(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) return false; else if (SwingUtilities.isLeftMouseButton(e)) return true; else return false; } }