Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt.im

Interface InputMethodRequests

java.lang.Object
|
+--java.awt.im.InputMethodRequests


public interface InputMethodRequests

This interface handles requests made by input methods on text editing components. A component must specify a handler for input methods that implements this interface, and which supports one of two user interfaces:

Since:Author:See Also:

Method Summary

java.text.AttributedCharacterIteratorcancelLatestCommittedText(java.text.AttributedCharacterIterator.Attribute attributes)

Gets the latest committed text, and removes it from the component's text body.
java.text.AttributedCharacterIteratorgetCommittedText(int beginIndex, int endIndex, java.text.AttributedCharacterIterator.Attribute attributes)

Gets an interator which provides access to the text and its attributes, except for the uncommitted text.
intgetCommittedTextLength()

Gets the length of committed text.
intgetInsertPositionOffset()

Gets the offset where the committed text exists in the text editing component.
java.awt.font.TextHitInfogetLocationOffset(int x, int y)

Get the text offset for the given screen coordinate.
java.text.AttributedCharacterIteratorgetSelectedText(java.text.AttributedCharacterIterator.Attribute attributes)

Gets the currently selected text.
java.awt.RectanglegetTextLocation(java.awt.font.TextHitInfo offset)

Gets the location of a given offset of the text.

Method Details

cancelLatestCommittedText

public AttributedCharacterIterator cancelLatestCommittedText(java.text.AttributedCharacterIterator.Attribute attributes)

Gets the latest committed text, and removes it from the component's text body. This allows an input method to provide an "Undo" command. In general, this should only be supported immediately after a commit, and not when other actions intervene; if not supported, simply return null. The input method may provide a list of attributes it is interested in; and the iterator need not provide information on the remaining attributes. If the attribute list is null, the iterator must list all attributes.

Parameters:

Returns:


getCommittedText

public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, java.text.AttributedCharacterIterator.Attribute attributes)

Gets an interator which provides access to the text and its attributes, except for the uncommitted text. The input method may provide a list of attributes it is interested in; and the iterator need not provide information on the remaining attributes. If the attribute list is null, the iterator must list all attributes.

Parameters:

Returns:


getCommittedTextLength

public int getCommittedTextLength()

Gets the length of committed text.

Returns:


getInsertPositionOffset

public int getInsertPositionOffset()

Gets the offset where the committed text exists in the text editing component. This can be used to examine the text surrounding the insert position.

Returns:


getLocationOffset

public TextHitInfo getLocationOffset(int x, int y)

Get the text offset for the given screen coordinate. The offset is relative to the composed text, and the return is null if it is outside the range of composed text. For example, this can be used to find where a mouse click should pop up a text composition window.

Parameters:

Returns:


getSelectedText

public AttributedCharacterIterator getSelectedText(java.text.AttributedCharacterIterator.Attribute attributes)

Gets the currently selected text. One use of this is to implement a "Reconvert" feature in an input method, which modifies the selection based on the text in the composition window. The input method may provide a list of attributes it is interested in; and the iterator need not provide information on the remaining attributes. If the attribute list is null, the iterator must list all attributes.

Parameters:

Returns:


getTextLocation

public Rectangle getTextLocation(java.awt.font.TextHitInfo offset)

Gets the location of a given offset of the text. This can be used to position a composition window near the location of where the composed text will be inserted.

If the component has composed text (from the most recent InputMethodEvent), then offset 0 indicates the location of the first character of this composed text. Otherwise, the offset is ignored, and the location should be the beginning of the final line of selected text (in horizontal left-to-right text, like English, this would be the lower left corner of the selction; in vertical top-to-bottom text, like Chinese, this would be the top right corner of the selection).

The location returned is a 0-thickness caret (either horizontal or vertical, depending on text flow), mapped to absolute screen coordinates.

Parameters:

Returns: