< prev index next >
src/java.desktop/share/classes/java/awt/Event.java
Print this page
*** 26,62 ****
import java.awt.event.*;
import java.io.*;
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
! * <code>Event</code> is a platform-independent class that
* encapsulates events from the platform's Graphical User
* Interface in the Java 1.0 event model. In Java 1.1
! * and later versions, the <code>Event</code> class is maintained
* only for backwards compatibility. The information in this
* class description is provided to assist programmers in
* converting Java 1.0 programs to the new event model.
* <p>
* In the Java 1.0 event model, an event contains an
* {@link Event#id} field
* that indicates what type of event it is and which other
! * <code>Event</code> variables are relevant for the event.
* <p>
* For keyboard events, {@link Event#key}
* contains a value indicating which key was activated, and
* {@link Event#modifiers} contains the
* modifiers for that event. For the KEY_PRESS and KEY_RELEASE
! * event ids, the value of <code>key</code> is the unicode
* character code for the key. For KEY_ACTION and
! * KEY_ACTION_RELEASE, the value of <code>key</code> is
* one of the defined action-key identifiers in the
! * <code>Event</code> class (<code>PGUP</code>,
! * <code>PGDN</code>, <code>F1</code>, <code>F2</code>, etc).
*
* @author Sami Shaio
* @since 1.0
*/
public class Event implements java.io.Serializable {
--- 26,62 ----
import java.awt.event.*;
import java.io.*;
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
! * {@code Event} is a platform-independent class that
* encapsulates events from the platform's Graphical User
* Interface in the Java 1.0 event model. In Java 1.1
! * and later versions, the {@code Event} class is maintained
* only for backwards compatibility. The information in this
* class description is provided to assist programmers in
* converting Java 1.0 programs to the new event model.
* <p>
* In the Java 1.0 event model, an event contains an
* {@link Event#id} field
* that indicates what type of event it is and which other
! * {@code Event} variables are relevant for the event.
* <p>
* For keyboard events, {@link Event#key}
* contains a value indicating which key was activated, and
* {@link Event#modifiers} contains the
* modifiers for that event. For the KEY_PRESS and KEY_RELEASE
! * event ids, the value of {@code key} is the unicode
* character code for the key. For KEY_ACTION and
! * KEY_ACTION_RELEASE, the value of {@code key} is
* one of the defined action-key identifiers in the
! * {@code Event} class ({@code PGUP},
! * {@code PGDN}, {@code F1}, {@code F2}, etc).
*
* @author Sami Shaio
* @since 1.0
*/
public class Event implements java.io.Serializable {
*** 291,311 ****
*/
public static final int KEY_RELEASE = 2 + KEY_EVENT;
/**
* The user has pressed a non-ASCII <em>action</em> key.
! * The <code>key</code> field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
*/
public static final int KEY_ACTION = 3 + KEY_EVENT;
/**
* The user has released a non-ASCII <em>action</em> key.
! * The <code>key</code> field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
*/
--- 291,311 ----
*/
public static final int KEY_RELEASE = 2 + KEY_EVENT;
/**
* The user has pressed a non-ASCII <em>action</em> key.
! * The {@code key} field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
*/
public static final int KEY_ACTION = 3 + KEY_EVENT;
/**
* The user has released a non-ASCII <em>action</em> key.
! * The {@code key} field contains a value that indicates
* that the event occurred on one of the action keys, which
* comprise the 12 function keys, the arrow (cursor) keys,
* Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
* Caps Lock, Num Lock, Pause, and Insert.
*/
*** 313,335 ****
/* Base for all mouse events. */
private static final int MOUSE_EVENT = 500;
/**
! * The user has pressed the mouse button. The <code>ALT_MASK</code>
* flag indicates that the middle button has been pressed.
! * The <code>META_MASK</code>flag indicates that the
* right button has been pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_DOWN = 1 + MOUSE_EVENT;
/**
! * The user has released the mouse button. The <code>ALT_MASK</code>
* flag indicates that the middle button has been released.
! * The <code>META_MASK</code>flag indicates that the
* right button has been released.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_UP = 2 + MOUSE_EVENT;
--- 313,335 ----
/* Base for all mouse events. */
private static final int MOUSE_EVENT = 500;
/**
! * The user has pressed the mouse button. The {@code ALT_MASK}
* flag indicates that the middle button has been pressed.
! * The {@code META_MASK} flag indicates that the
* right button has been pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_DOWN = 1 + MOUSE_EVENT;
/**
! * The user has released the mouse button. The {@code ALT_MASK}
* flag indicates that the middle button has been released.
! * The {@code META_MASK} flag indicates that the
* right button has been released.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_UP = 2 + MOUSE_EVENT;
*** 349,360 ****
*/
public static final int MOUSE_EXIT = 5 + MOUSE_EVENT;
/**
* The user has moved the mouse with a button pressed. The
! * <code>ALT_MASK</code> flag indicates that the middle
! * button is being pressed. The <code>META_MASK</code> flag indicates
* that the right button is being pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_DRAG = 6 + MOUSE_EVENT;
--- 349,360 ----
*/
public static final int MOUSE_EXIT = 5 + MOUSE_EVENT;
/**
* The user has moved the mouse with a button pressed. The
! * {@code ALT_MASK} flag indicates that the middle
! * button is being pressed. The {@code META_MASK} flag indicates
* that the right button is being pressed.
* @see java.awt.Event#ALT_MASK
* @see java.awt.Event#META_MASK
*/
public static final int MOUSE_DRAG = 6 + MOUSE_EVENT;
*** 464,474 ****
*/
public long when;
/**
* Indicates which type of event the event is, and which
! * other <code>Event</code> variables are relevant for the event.
* This has been replaced by AWTEvent.getID()
*
* @serial
* @see java.awt.AWTEvent#getID()
*/
--- 464,474 ----
*/
public long when;
/**
* Indicates which type of event the event is, and which
! * other {@code Event} variables are relevant for the event.
* This has been replaced by AWTEvent.getID()
*
* @serial
* @see java.awt.AWTEvent#getID()
*/
*** 516,539 ****
* @see java.awt.event.InputEvent#getModifiers()
*/
public int modifiers;
/**
! * For <code>MOUSE_DOWN</code> events, this field indicates the
* number of consecutive clicks. For other events, its value is
! * <code>0</code>.
* This field has been replaced by MouseEvent.getClickCount().
*
* @serial
* @see java.awt.event.MouseEvent#getClickCount()
*/
public int clickCount;
/**
* An arbitrary argument of the event. The value of this field
* depends on the type of event.
! * <code>arg</code> has been replaced by event specific property.
*
* @serial
*/
public Object arg;
--- 516,539 ----
* @see java.awt.event.InputEvent#getModifiers()
*/
public int modifiers;
/**
! * For {@code MOUSE_DOWN} events, this field indicates the
* number of consecutive clicks. For other events, its value is
! * {@code 0}.
* This field has been replaced by MouseEvent.getClickCount().
*
* @serial
* @see java.awt.event.MouseEvent#getClickCount()
*/
public int clickCount;
/**
* An arbitrary argument of the event. The value of this field
* depends on the type of event.
! * {@code arg} has been replaced by event specific property.
*
* @serial
*/
public Object arg;
*** 606,620 ****
accessed from C.
*/
private static native void initIDs();
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
! * Creates an instance of <code>Event</code> with the specified target
* component, time stamp, event type, <i>x</i> and <i>y</i>
* coordinates, keyboard key, state of the modifier keys, and
* argument.
* @param target the target component.
* @param when the time stamp.
--- 606,620 ----
accessed from C.
*/
private static native void initIDs();
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
! * Creates an instance of {@code Event} with the specified target
* component, time stamp, event type, <i>x</i> and <i>y</i>
* coordinates, keyboard key, state of the modifier keys, and
* argument.
* @param target the target component.
* @param when the time stamp.
*** 657,674 ****
default:
}
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
! * Creates an instance of <code>Event</code>, with the specified target
* component, time stamp, event type, <i>x</i> and <i>y</i>
* coordinates, keyboard key, state of the modifier keys, and an
! * argument set to <code>null</code>.
* @param target the target component.
* @param when the time stamp.
* @param id the event type.
* @param x the <i>x</i> coordinate.
* @param y the <i>y</i> coordinate.
--- 657,674 ----
default:
}
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
! * Creates an instance of {@code Event}, with the specified target
* component, time stamp, event type, <i>x</i> and <i>y</i>
* coordinates, keyboard key, state of the modifier keys, and an
! * argument set to {@code null}.
* @param target the target component.
* @param when the time stamp.
* @param id the event type.
* @param x the <i>x</i> coordinate.
* @param y the <i>y</i> coordinate.
*** 678,705 ****
public Event(Object target, long when, int id, int x, int y, int key, int modifiers) {
this(target, when, id, x, y, key, modifiers, null);
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
! * Creates an instance of <code>Event</code> with the specified
* target component, event type, and argument.
* @param target the target component.
* @param id the event type.
* @param arg the specified argument.
*/
public Event(Object target, int id, Object arg) {
this(target, 0, id, 0, 0, 0, 0, arg);
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Translates this event so that its <i>x</i> and <i>y</i>
* coordinates are increased by <i>dx</i> and <i>dy</i>,
* respectively.
* <p>
--- 678,705 ----
public Event(Object target, long when, int id, int x, int y, int key, int modifiers) {
this(target, when, id, x, y, key, modifiers, null);
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
! * Creates an instance of {@code Event} with the specified
* target component, event type, and argument.
* @param target the target component.
* @param id the event type.
* @param arg the specified argument.
*/
public Event(Object target, int id, Object arg) {
this(target, 0, id, 0, 0, 0, 0, arg);
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Translates this event so that its <i>x</i> and <i>y</i>
* coordinates are increased by <i>dx</i> and <i>dy</i>,
* respectively.
* <p>
*** 714,775 ****
this.x += dx;
this.y += dy;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Checks if the Shift key is down.
! * @return <code>true</code> if the key is down;
! * <code>false</code> otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#controlDown
* @see java.awt.Event#metaDown
*/
public boolean shiftDown() {
return (modifiers & SHIFT_MASK) != 0;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Checks if the Control key is down.
! * @return <code>true</code> if the key is down;
! * <code>false</code> otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#shiftDown
* @see java.awt.Event#metaDown
*/
public boolean controlDown() {
return (modifiers & CTRL_MASK) != 0;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Checks if the Meta key is down.
*
! * @return <code>true</code> if the key is down;
! * <code>false</code> otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#shiftDown
* @see java.awt.Event#controlDown
*/
public boolean metaDown() {
return (modifiers & META_MASK) != 0;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
*/
void consume() {
switch(id) {
case KEY_PRESS:
case KEY_RELEASE:
--- 714,775 ----
this.x += dx;
this.y += dy;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Checks if the Shift key is down.
! * @return {@code true} if the key is down;
! * {@code false} otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#controlDown
* @see java.awt.Event#metaDown
*/
public boolean shiftDown() {
return (modifiers & SHIFT_MASK) != 0;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Checks if the Control key is down.
! * @return {@code true} if the key is down;
! * {@code false} otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#shiftDown
* @see java.awt.Event#metaDown
*/
public boolean controlDown() {
return (modifiers & CTRL_MASK) != 0;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Checks if the Meta key is down.
*
! * @return {@code true} if the key is down;
! * {@code false} otherwise.
* @see java.awt.Event#modifiers
* @see java.awt.Event#shiftDown
* @see java.awt.Event#controlDown
*/
public boolean metaDown() {
return (modifiers & META_MASK) != 0;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
*/
void consume() {
switch(id) {
case KEY_PRESS:
case KEY_RELEASE:
*** 781,802 ****
// event type cannot be consumed
}
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
*/
boolean isConsumed() {
return consumed;
}
/*
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Returns the integer key-code associated with the key in this event,
* as described in java.awt.Event.
*/
static int getOldEventKey(KeyEvent e) {
--- 781,802 ----
// event type cannot be consumed
}
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
*/
boolean isConsumed() {
return consumed;
}
/*
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Returns the integer key-code associated with the key in this event,
* as described in java.awt.Event.
*/
static int getOldEventKey(KeyEvent e) {
*** 808,820 ****
}
return (int)e.getKeyChar();
}
/*
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Returns a new KeyEvent char which corresponds to the int key
* of this old event.
*/
char getKeyEventChar() {
--- 808,820 ----
}
return (int)e.getKeyChar();
}
/*
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Returns a new KeyEvent char which corresponds to the int key
* of this old event.
*/
char getKeyEventChar() {
*** 825,843 ****
}
return (char)key;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
! * Returns a string representing the state of this <code>Event</code>.
* This method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not be
! * <code>null</code>.
*
* @return the parameter string of this event
*/
protected String paramString() {
String str = "id=" + id + ",x=" + x + ",y=" + y;
--- 825,843 ----
}
return (char)key;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
! * Returns a string representing the state of this {@code Event}.
* This method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not be
! * {@code null}.
*
* @return the parameter string of this event
*/
protected String paramString() {
String str = "id=" + id + ",x=" + x + ",y=" + y;
*** 861,873 ****
}
return str;
}
/**
! * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the <code>AWTEvent</code> class and its subclasses.
* <p>
* Returns a representation of this event's values as a string.
* @return a string that represents the event and the values
* of its member fields.
* @see java.awt.Event#paramString
--- 861,873 ----
}
return str;
}
/**
! * <b>NOTE:</b> The {@code Event} class is obsolete and is
* available only for backwards compatibility. It has been replaced
! * by the {@code AWTEvent} class and its subclasses.
* <p>
* Returns a representation of this event's values as a string.
* @return a string that represents the event and the values
* of its member fields.
* @see java.awt.Event#paramString
< prev index next >