J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package java.awt.event; |
| 27 | |
| 28 | /** |
| 29 | * An abstract adapter class for receiving mouse events. |
| 30 | * The methods in this class are empty. This class exists as |
| 31 | * convenience for creating listener objects. |
| 32 | * <P> |
| 33 | * Mouse events let you track when a mouse is pressed, released, clicked, |
| 34 | * moved, dragged, when it enters a component, when it exits and |
| 35 | * when a mouse wheel is moved. |
| 36 | * <P> |
| 37 | * Extend this class to create a {@code MouseEvent} |
| 38 | * (including drag and motion events) or/and {@code MouseWheelEvent} |
| 39 | * listener and override the methods for the events of interest. (If you implement the |
| 40 | * {@code MouseListener}, |
| 41 | * {@code MouseMotionListener} |
| 42 | * interface, you have to define all of |
| 43 | * the methods in it. This abstract class defines null methods for them |
| 44 | * all, so you can only have to define methods for events you care about.) |
| 45 | * <P> |
| 46 | * Create a listener object using the extended class and then register it with |
| 47 | * a component using the component's {@code addMouseListener} |
| 48 | * {@code addMouseMotionListener}, {@code addMouseWheelListener} |
| 49 | * methods. |
| 50 | * The relevant method in the listener object is invoked and the {@code MouseEvent} |
| 51 | * or {@code MouseWheelEvent} is passed to it in following cases: |
| 52 | * <p><ul> |
| 53 | * <li>when a mouse button is pressed, released, or clicked (pressed and released) |
| 54 | * <li>when the mouse cursor enters or exits the component |
| 55 | * <li>when the mouse wheel rotated, or mouse moved or dragged |
| 56 | * </ul> |
| 57 | * |
| 58 | * @author Carl Quinn |
| 59 | * @author Andrei Dmitriev |
| 60 | * |
| 61 | * @see MouseEvent |
| 62 | * @see MouseWheelEvent |
| 63 | * @see MouseListener |
| 64 | * @see MouseMotionListener |
| 65 | * @see MouseWheelListener |
| 66 | * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/mouselistener.html">Tutorial: Writing a Mouse Listener</a> |
| 67 | * |
| 68 | * @since 1.1 |
| 69 | */ |
| 70 | public abstract class MouseAdapter implements MouseListener, MouseWheelListener, MouseMotionListener { |
| 71 | /** |
| 72 | * {@inheritDoc} |
| 73 | */ |
| 74 | public void mouseClicked(MouseEvent e) {} |
| 75 | |
| 76 | /** |
| 77 | * {@inheritDoc} |
| 78 | */ |
| 79 | public void mousePressed(MouseEvent e) {} |
| 80 | |
| 81 | /** |
| 82 | * {@inheritDoc} |
| 83 | */ |
| 84 | public void mouseReleased(MouseEvent e) {} |
| 85 | |
| 86 | /** |
| 87 | * {@inheritDoc} |
| 88 | */ |
| 89 | public void mouseEntered(MouseEvent e) {} |
| 90 | |
| 91 | /** |
| 92 | * {@inheritDoc} |
| 93 | */ |
| 94 | public void mouseExited(MouseEvent e) {} |
| 95 | |
| 96 | /** |
| 97 | * {@inheritDoc} |
| 98 | * @since 1.6 |
| 99 | */ |
| 100 | public void mouseWheelMoved(MouseWheelEvent e){} |
| 101 | |
| 102 | /** |
| 103 | * {@inheritDoc} |
| 104 | * @since 1.6 |
| 105 | */ |
| 106 | public void mouseDragged(MouseEvent e){} |
| 107 | |
| 108 | /** |
| 109 | * {@inheritDoc} |
| 110 | * @since 1.6 |
| 111 | */ |
| 112 | public void mouseMoved(MouseEvent e){} |
| 113 | } |