java.awt.event
Class InputMethodEvent
java.lang.Object
|
+--java.util.EventObject
|
+--java.awt.AWTEvent
|
+--java.awt.event.InputMethodEvent
public class
InputMethodEventextends
AWTEvent This class is for event generated by change in a text input method.
Since:Author:- Aaron M. Renn <arenn@urbanophile.com>
See Also:
InputMethodEvent(java.awt.Component source, int id, long when, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
|
InputMethodEvent(java.awt.Component source, int id, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
|
InputMethodEvent(java.awt.Component source, int id, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
|
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.
InputMethodEvent
public InputMethodEvent(java.awt.Component source, int id, java.awt.font.TextHitInfo caret, java.awt.font.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.
Since:Parameters:
Throws:
InputMethodEvent
public InputMethodEvent(java.awt.Component source, int id, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
Initializes a new instance of InputMethodEvent
with the
specified source, id, text, char count, caret, and visible position.
Since:Parameters:
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
InputMethodEvent
public InputMethodEvent(java.awt.Component source, int id, long when, java.text.AttributedCharacterIterator text, int committedCharacterCount, java.awt.font.TextHitInfo caret, java.awt.font.TextHitInfo visiblePosition)
Initializes a new instance of InputMethodEvent
with the
specified source, id, timestamp, text, char count, caret, and visible
position.
Since:Parameters:
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
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.
Since:Returns:
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