All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.awt.event.InputEvent Maven / Gradle / Ivy

/*

NOTICE


(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.

Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below. For example, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.

Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative, as opposed to normative, use. The file and any files generated from it may be used to generate other informative documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. The file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms.

Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.

This work corresponds to the API signatures of JSR 217: Personal Basis Profile 1.1. In the event of a discrepency between this work and the JSR 217 specification, which is available at http://www.jcp.org/en/jsr/detail?id=217, the latter takes precedence. */ package java.awt.event; // import java.awt.Event; import java.awt.Component; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; /** * The root event class for all component-level input events. * * Input events are delivered to listeners before they are * processed normally by the source where they originated. * This allows listeners and component subclasses to "consume" * the event so that the source will not process them in their * default manner. For example, consuming mousePressed events * on a Button component will prevent the Button from being * activated. * *

* Note: Applications should not depend on all or even any of the * input event modifiers defined here to be generated by an implementation. * * *

* Note: The timestamps used by this class report the difference, * measured in milliseconds, between the time of the event and midnight, * January 1, 1970 UTC * (similar to {@link java.lang.System.currentTimeMillis}). * * @author Carl Quinn * @version 1.29 01/23/03 * * @see KeyEvent * @see KeyAdapter * @see MouseEvent * @see MouseAdapter * @see MouseMotionAdapter * * @since 1.1 */ public abstract class InputEvent extends ComponentEvent { /** * The Shift key modifier constant. * It is recommended that SHIFT_DOWN_MASK be used instead. */ public static final int SHIFT_MASK = 1 << 0; /** * The Control key modifier constant. * It is recommended that CTRL_DOWN_MASK be used instead. */ public static final int CTRL_MASK = 1 << 1; /** * The Meta key modifier constant. * It is recommended that META_DOWN_MASK be used instead. */ public static final int META_MASK = 1 << 2; /** * The Alt key modifier constant. * It is recommended that ALT_DOWN_MASK be used instead. */ public static final int ALT_MASK = 1 << 3; /** * The AltGraph key modifier constant. */ public static final int ALT_GRAPH_MASK = 1 << 5; /** * The Mouse Button1 modifier constant. * It is recommended that BUTTON1_DOWN_MASK be used instead. */ public static final int BUTTON1_MASK = 1 << 4; /** * The Mouse Button2 modifier constant. * It is recommended that BUTTON2_DOWN_MASK be used instead. */ public static final int BUTTON2_MASK = 1 << 3; /** * The Mouse Button3 modifier constant. * It is recommended that BUTTON3_DOWN_MASK be used instead. */ public static final int BUTTON3_MASK = 1 << 2; /** * The Shift key extended modifier constant. * @since 1.4 */ public static final int SHIFT_DOWN_MASK = 1 << 6; /** * The Control key extended modifier constant. * @since 1.4 */ public static final int CTRL_DOWN_MASK = 1 << 7; /** * The Meta key extended modifier constant. * @since 1.4 */ public static final int META_DOWN_MASK = 1 << 8; /** * The Alt key extended modifier constant. * @since 1.4 */ public static final int ALT_DOWN_MASK = 1 << 9; /** * The Mouse Button1 extended modifier constant. * @since 1.4 */ public static final int BUTTON1_DOWN_MASK = 1 << 10; /** * The Mouse Button2 extended modifier constant. * @since 1.4 */ public static final int BUTTON2_DOWN_MASK = 1 << 11; /** * The Mouse Button3 extended modifier constant. * @since 1.4 */ public static final int BUTTON3_DOWN_MASK = 1 << 12; /** * The AltGraph key extended modifier constant. * @since 1.4 */ public static final int ALT_GRAPH_DOWN_MASK = 1 << 13; /** * The input event's Time stamp in UTC format. The time stamp * indicates when the input event was created. * * @serial * @see #getWhen() */ long when; /** * The state of the modifier mask at the time the input * event was fired. * * @serial * @see #getModifiers() * @see #getModifiersEx() * @see java.awt.event.KeyEvent * @see java.awt.event.MouseEvent */ int modifiers; InputEvent(Component source, int id, long when, int modifiers){ super(source, id); } // /* // * This hidden constructor does not necessarily correspond to // * a constructor in the original source file -- it keeps javadoc // * from generating an inappropriate default constructor. // */ // private InputEvent() { super(null, 0); } /** * Returns whether or not the Shift modifier is down on this event. */ public boolean isShiftDown() {return false; } /** * Returns whether or not the Control modifier is down on this event. */ public boolean isControlDown() {return false; } /** * Returns whether or not the Meta modifier is down on this event. */ public boolean isMetaDown() { return false; } /** * Returns whether or not the Alt modifier is down on this event. */ public boolean isAltDown() { return false; } /** * Returns whether or not the AltGraph modifier is down on this event. */ public boolean isAltGraphDown() {return false; } /** * Returns the timestamp of when this event occurred. */ public long getWhen() {return 0; } /** * Returns the modifier mask for this event. */ public int getModifiers() {return 0; } /** * Returns the extended modifier mask for this event. * Extended modifiers represent the state of all modal keys, * such as ALT, CTRL, META, and the mouse buttons just after * the event occurred *

* For example, if the user presses button 1 followed by * button 2, and then releases them in the same order, * the following sequence of events is generated: *

     *    MOUSE_PRESSED:  BUTTON1_DOWN_MASK
     *    MOUSE_PRESSED:  BUTTON1_DOWN_MASK | BUTTON2_DOWN_MASK
     *    MOUSE_RELEASED: BUTTON2_DOWN_MASK
     *    MOUSE_CLICKED:  BUTTON2_DOWN_MASK
     *    MOUSE_RELEASED: 
     *    MOUSE_CLICKED:  
     * 
*

* It is not recommended to compare the return value of this method * using == because new modifiers can be added in the future. * For example, the appropriate way to check that SHIFT and BUTTON1 are * down, but CTRL is up is demonstrated by the following code: *

     *    int onmask = SHIFT_DOWN_MASK | BUTTON1_DOWN_MASK;
     *    int offmask = CTRL_DOWN_MASK;
     *    if (event.getModifiersEx() & (onmask | offmask) == onmask) {
     *        ...
     *    }
     * 
* The above code will work even if new modifiers are added. * * @since 1.4 */ public int getModifiersEx() { return 0; } /** * Consumes this event so that it will not be processed * in the default manner by the source which originated it. */ public void consume() { } /** * Returns whether or not this event has been consumed. * @see #consume */ public boolean isConsumed() {return false; } // state serialization compatibility with JDK 1.1 static final long serialVersionUID = -2482525981698309786L; /** * Returns a String describing the extended modifier keys and * mouse buttons, such as "Shift", "Button1", or "Ctrl+Shift". * These strings can be localized by changing the * awt.properties file. * * @param modifiers a modifier mask describing the extended * modifier keys and mouse buttons for the event * @return a text description of the combination of extended * modifier keys and mouse buttons that were held down * during the event. * @since 1.4 */ public static String getModifiersExText(int modifiers) { return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy