|
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Handling Mouse Clicks
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());
}
}
}
|
Examplets provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
|