java.awt.event
Class InputMethodEvent

java.lang.Object
  extended by java.util.EventObject
      extended by java.awt.AWTEvent
          extended by java.awt.event.InputMethodEvent
All Implemented Interfaces:
Serializable

public class InputMethodEvent
extends AWTEvent

This class is for event generated by change in a text input method.

Since:
1.2
See Also:
InputMethodListener, Serialized Form

Field Summary
static int CARET_POSITION_CHANGED
          This event id indicates that the input method curor point has changed.
static int INPUT_METHOD_FIRST
          This is the first id in the range of event ids used by this class.
static int INPUT_METHOD_LAST
          This is the last id in the range of event ids used by this class.
static int INPUT_METHOD_TEXT_CHANGED
          This event id indicates that the text in the input method has changed.
 
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, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition)
          Initializes a new instance of InputMethodEvent with the specified source, id, text, char count, caret, and visible position.
InputMethodEvent(Component source, int id, long when, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition)
          Initializes a new instance of InputMethodEvent with the specified source, id, timestamp, text, char count, caret, and visible position.
InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition)
          Initializes a new instance of InputMethodEvent with the specified source, id, caret, and visible position, and with a null text and char count.
 
Method Summary
 void consume()
          This method consumes the event.
 TextHitInfo getCaret()
          Returns the caret position.
 int getCommittedCharacterCount()
          Returns the number of committed characters in the input method text.
 AttributedCharacterIterator getText()
          This method returns the input method text.
 TextHitInfo getVisiblePosition()
          Returns the position that is most important to be visible, or null if such a hint is not necessary.
 long getWhen()
          Return the timestamp of this event.
 boolean isConsumed()
          This method tests whether or not this event has been consumed.
 String paramString()
          This method returns a string identifying the event.
 
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

INPUT_METHOD_FIRST

public static final int INPUT_METHOD_FIRST
This is the first id in the range of event ids used by this class.

See Also:
Constant Field Values

INPUT_METHOD_TEXT_CHANGED

public static final int INPUT_METHOD_TEXT_CHANGED
This event id indicates that the text in the input method has changed.

See Also:
Constant Field Values

CARET_POSITION_CHANGED

public static final int CARET_POSITION_CHANGED
This event id indicates that the input method curor point has changed.

See Also:
Constant Field Values

INPUT_METHOD_LAST

public static final int INPUT_METHOD_LAST
This is the last id in the range of event ids used by this class.

See Also:
Constant Field Values
Constructor Detail

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        long when,
                        AttributedCharacterIterator text,
                        int committedCharacterCount,
                        TextHitInfo caret,
                        TextHitInfo visiblePosition)
Initializes a new instance of InputMethodEvent with the specified source, id, timestamp, text, char count, caret, and visible position.

Parameters:
source - the source that generated the event
id - the event id
when - the timestamp of the event
text - the input text
committedCharacterCount - the number of committed characters
caret - the caret position
visiblePosition - the position most important to make visible
Throws:
IllegalArgumentException - if source is null, id is invalid, id is CARET_POSITION_CHANGED and text is non-null, or if committedCharacterCount is out of range
Since:
1.4

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        AttributedCharacterIterator text,
                        int committedCharacterCount,
                        TextHitInfo caret,
                        TextHitInfo visiblePosition)
Initializes a new instance of InputMethodEvent with the specified source, id, text, char count, caret, and visible position.

Parameters:
source - the source that generated the event
id - the event id
text - the input text
committedCharacterCount - the number of committed characters
caret - the caret position
visiblePosition - the position most important to make visible
Throws:
IllegalArgumentException - if source is null, id is invalid, id is CARET_POSITION_CHANGED and text is non-null, or if committedCharacterCount is out of range
Since:
1.4

InputMethodEvent

public InputMethodEvent(Component source,
                        int id,
                        TextHitInfo caret,
                        TextHitInfo visiblePosition)
Initializes a new instance of InputMethodEvent with the specified source, id, caret, and visible position, and with a null text and char count.

Parameters:
source - the source that generated the event
id - the event id
caret - the caret position
visiblePosition - the position most important to make visible
Throws:
IllegalArgumentException - if source is null or id is invalid
Since:
1.4
Method Detail

getText

public AttributedCharacterIterator getText()
This method returns the input method text. This can be null, and will always be null for CARET_POSITION_CHANGED events. Characters from 0 to getCommittedCharacterCount()-1 have been committed, the remaining characters are composed text.

Returns:
the input method text, or null

getCommittedCharacterCount

public int getCommittedCharacterCount()
Returns the number of committed characters in the input method text.

Returns:
the number of committed characters in the input method text

getCaret

public TextHitInfo getCaret()
Returns the caret position. The caret offset is relative to the composed text of the most recent INPUT_METHOD_TEXT_CHANGED event.

Returns:
the caret position, or null

getVisiblePosition

public TextHitInfo getVisiblePosition()
Returns the position that is most important to be visible, or null if such a hint is not necessary. The caret offset is relative to the composed text of the most recent INPUT_METHOD_TEXT_CHANGED event.

Returns:
the position that is most important to be visible

consume

public void consume()
This method consumes the event. A consumed event is not processed in the default manner by the component that generated it.

Overrides:
consume in class AWTEvent

isConsumed

public boolean isConsumed()
This method tests whether or not this event has been consumed.

Overrides:
isConsumed in class AWTEvent
Returns:
true if the event has been consumed

getWhen

public long getWhen()
Return the timestamp of this event.

Returns:
the timestamp
Since:
1.4

paramString

public String paramString()
This method returns a string identifying the event. This contains the event ID, the committed and composed characters separated by '+', the number of committed characters, the caret, and the visible position.

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