java.awt.event
Class InputMethodEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--java.awt.AWTEvent
              |
              +--java.awt.event.InputMethodEvent
All Implemented Interfaces:
Serializable

public class InputMethodEvent
extends AWTEvent

Safe:

See Also:
Serialized Form

Field Summary
private  java.awt.font.TextHitInfo caret
           
static int CARET_POSITION_CHANGED
          Enabled: The event type indicating a changed insertion point in input method text.
private  int committedCharacterCount
           
static int INPUT_METHOD_FIRST
          Enabled: Marks the first integer id for the range of input method event ids.
static int INPUT_METHOD_LAST
          Enabled: Marks the last integer id for the range of input method event ids.
static int INPUT_METHOD_TEXT_CHANGED
          Enabled: The event type indicating changed input method text.
private static long serialVersionUID
          Serial Version ID.
private  java.text.AttributedCharacterIterator text
           
private  java.awt.font.TextHitInfo visiblePosition
           
(package private)  long when
          The time stamp that indicates when the event was created.
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
InputMethodEvent(Component source, int id, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
          Suppressed: Constructs an InputMethodEvent with the specified source component, type, text, caret, and visiblePosition.
InputMethodEvent(Component source, int id, long when, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
          Suppressed: Constructs an InputMethodEvent with the specified source component, type, time, text, caret, and visiblePosition.
InputMethodEvent(Component source, int id, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
          Suppressed: Constructs an InputMethodEvent with the specified source component, type, caret, and visiblePosition.
 
Method Summary
 void consume()
          Enabled: Consumes this event so that it will not be processed in the default manner by the source which originated it.
 java.awt.font.TextHitInfo getCaret()
          Enabled: Gets the caret.
 int getCommittedCharacterCount()
          Enabled: Gets the number of committed characters in the text.
 java.text.AttributedCharacterIterator getText()
          Enabled: Gets the combined committed and composed text.
 java.awt.font.TextHitInfo getVisiblePosition()
          Enabled: Gets the position that's most important to be visible.
 long getWhen()
          Suppressed: Returns the time stamp of when this event occurred.
 boolean isConsumed()
          Enabled: Returns whether or not this event has been consumed.
 String paramString()
          Suppressed: Returns a parameter string identifying this event.
private  void readObject(ObjectInputStream s)
          Initializes the when field if it is not present in the object input stream.
 
Methods inherited from class java.awt.AWTEvent
getID, setSource, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial Version ID.


INPUT_METHOD_FIRST

public static final int INPUT_METHOD_FIRST
Enabled: Marks the first integer id for the range of input method event ids.


INPUT_METHOD_TEXT_CHANGED

public static final int INPUT_METHOD_TEXT_CHANGED
Enabled: The event type indicating changed input method text. This event is generated by input methods while processing input.


CARET_POSITION_CHANGED

public static final int CARET_POSITION_CHANGED
Enabled: The event type indicating a changed insertion point in input method text. This event is generated by input methods while processing input if only the caret changed.


INPUT_METHOD_LAST

public static final int INPUT_METHOD_LAST
Enabled: Marks the last integer id for the range of input method event ids.


when

long when
The time stamp that indicates when the event was created.

Since:
1.4
See Also:
getWhen()

text

private transient java.text.AttributedCharacterIterator text

committedCharacterCount

private transient int committedCharacterCount

caret

private transient java.awt.font.TextHitInfo caret

visiblePosition

private transient java.awt.font.TextHitInfo visiblePosition
Constructor Detail

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        long when,
                        java.text.AttributedCharacterIterator text,
                        int committedCharacterCount,
                        java.awt.font.TextHitInfo caret,
                        java.awt.font.TextHitInfo visiblePosition)
Suppressed: Constructs an InputMethodEvent with the specified source component, type, time, text, caret, and visiblePosition.

The offsets of caret and visiblePosition are relative to the current composed text; that is, the composed text within text if this is an INPUT_METHOD_TEXT_CHANGED event, the composed text within the text of the preceding INPUT_METHOD_TEXT_CHANGED event otherwise.

Parameters:
source - the object where the event originated
id - the event type
when - a long integer that specifies the time the event occurred
text - the combined committed and composed text, committed text first; must be null when the event type is CARET_POSITION_CHANGED; may be null for INPUT_METHOD_TEXT_CHANGED if there's no committed or composed text
committedCharacterCount - the number of committed characters in the text
caret - the caret (a.k.a. insertion point); null if there's no caret within current composed text
visiblePosition - the position that's most important to be visible; null if there's no recommendation for a visible position within current composed text
Since:
1.4

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        java.text.AttributedCharacterIterator text,
                        int committedCharacterCount,
                        java.awt.font.TextHitInfo caret,
                        java.awt.font.TextHitInfo visiblePosition)
Suppressed: Constructs an InputMethodEvent with the specified source component, type, text, caret, and visiblePosition.

The offsets of caret and visiblePosition are relative to the current composed text; that is, the composed text within text if this is an INPUT_METHOD_TEXT_CHANGED event, the composed text within the text of the preceding INPUT_METHOD_TEXT_CHANGED event otherwise. The time stamp for this event is initialized by invoking java.awt.EventQueue#getMostRecentEventTime().

Parameters:
source - the object where the event originated
id - the event type
text - the combined committed and composed text, committed text first; must be null when the event type is CARET_POSITION_CHANGED; may be null for INPUT_METHOD_TEXT_CHANGED if there's no committed or composed text
committedCharacterCount - the number of committed characters in the text
caret - the caret (a.k.a. insertion point); null if there's no caret within current composed text
visiblePosition - the position that's most important to be visible; null if there's no recommendation for a visible position within current composed text

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        java.awt.font.TextHitInfo caret,
                        java.awt.font.TextHitInfo visiblePosition)
Suppressed: Constructs an InputMethodEvent with the specified source component, type, caret, and visiblePosition. The text is set to null, committedCharacterCount to 0.

The offsets of caret and visiblePosition are relative to the current composed text; that is, the composed text within the text of the preceding INPUT_METHOD_TEXT_CHANGED event if the event being constructed as a CARET_POSITION_CHANGED event. For an INPUT_METHOD_TEXT_CHANGED event without text, caret and visiblePosition must be null. The time stamp for this event is initialized by invoking java.awt.EventQueue#getMostRecentEventTime().

Parameters:
source - the object where the event originated
id - the event type
caret - the caret (a.k.a. insertion point); null if there's no caret within current composed text
visiblePosition - the position that's most important to be visible; null if there's no recommendation for a visible position within current composed text
Method Detail

getText

public java.text.AttributedCharacterIterator getText()
Enabled: Gets the combined committed and composed text. Characters from index 0 to index getCommittedCharacterCount() - 1 are committed text, the remaining characters are composed text.

Returns:
the text. Always null for CARET_POSITION_CHANGED; may be null for INPUT_METHOD_TEXT_CHANGED if there's no composed or committed text.

getCommittedCharacterCount

public int getCommittedCharacterCount()
Enabled: Gets the number of committed characters in the text.


getCaret

public java.awt.font.TextHitInfo getCaret()
Enabled: Gets the caret.

The offset of the caret is relative to the current composed text; that is, the composed text within getText() if this is an INPUT_METHOD_TEXT_CHANGED event, the composed text within getText() of the preceding INPUT_METHOD_TEXT_CHANGED event otherwise.

Returns:
the caret (a.k.a. insertion point). Null if there's no caret within current composed text.

getVisiblePosition

public java.awt.font.TextHitInfo getVisiblePosition()
Enabled: Gets the position that's most important to be visible.

The offset of the visible position is relative to the current composed text; that is, the composed text within getText() if this is an INPUT_METHOD_TEXT_CHANGED event, the composed text within getText() of the preceding INPUT_METHOD_TEXT_CHANGED event otherwise.

Returns:
the position that's most important to be visible. Null if there's no recommendation for a visible position within current composed text.

consume

public void consume()
Enabled: Consumes this event so that it will not be processed in the default manner by the source which originated it.

Overrides:
consume in class AWTEvent

isConsumed

public boolean isConsumed()
Enabled: Returns whether or not this event has been consumed.

Overrides:
isConsumed in class AWTEvent
See Also:
consume()

getWhen

public long getWhen()
Suppressed: Returns the time stamp of when this event occurred.

Returns:
this event's timestamp
Since:
1.4

paramString

public String paramString()
Suppressed: Returns a parameter string identifying this event. This method is useful for event-logging and for debugging. It contains the event ID in text form, the characters of the committed and composed text separated by "+", the number of committed characters, the caret, and the visible position.

Overrides:
paramString in class AWTEvent
Returns:
a string identifying the event and its attributes

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException
Initializes the when field if it is not present in the object input stream. In that case, the field will be initialized by invoking java.awt.EventQueue#getMostRecentEventTime().

ClassNotFoundException
IOException


comments?