java.awt.event

Class InputMethodEvent

public class InputMethodEvent extends AWTEvent

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

Since: 1.2

See Also: InputMethodListener

UNKNOWN: updated to 1.4

Field Summary
static intCARET_POSITION_CHANGED
This event id indicates that the input method curor point has changed.
static intINPUT_METHOD_FIRST
This is the first id in the range of event ids used by this class.
static intINPUT_METHOD_LAST
This is the last id in the range of event ids used by this class.
static intINPUT_METHOD_TEXT_CHANGED
This event id indicates that the text in the input method has changed.
Constructor Summary
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, 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, 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
voidconsume()
This method consumes the event.
TextHitInfogetCaret()
Returns the caret position.
intgetCommittedCharacterCount()
Returns the number of committed characters in the input method text.
AttributedCharacterIteratorgetText()
This method returns the input method text.
TextHitInfogetVisiblePosition()
Returns the position that is most important to be visible, or null if such a hint is not necessary.
longgetWhen()
Return the timestamp of this event.
booleanisConsumed()
This method tests whether or not this event has been consumed.
StringparamString()
This method returns a string identifying the event.

Field Detail

CARET_POSITION_CHANGED

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

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.

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.

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.

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

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.

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

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

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

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

getWhen

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

Returns: the timestamp

Since: 1.4

isConsumed

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

Returns: true if the event has been consumed

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.

Returns: a string identifying the event