component.addMouseListener(new MyMouseListener()); public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { processLeft(evt.getPoint()); } if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) { processMiddle(evt.getPoint()); } if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { processRight(evt.getPoint()); } } }
Related Examples |