public class

InputMethodContext

extends InputContext
implements InputMethodContext
java.lang.Object
   ↳ java.awt.im.InputContext
     ↳ sun.awt.im.InputContext
       ↳ sun.awt.im.InputMethodContext

Class Overview

The InputMethodContext class provides methods that input methods can use to communicate with their client components. It is a subclass of InputContext, which provides methods for use by components.

Summary

Public Constructors
InputMethodContext()
Constructs an InputMethodContext.
Public Methods
AttributedCharacterIterator cancelLatestCommittedText(Attribute[] attributes)
Calls the current client component's implementation of cancelLatestCommittedText.
JFrame createInputMethodJFrame(String title, boolean attachToInputContext)
Creates a top-level Swing JFrame for use by the input method.
Window createInputMethodWindow(String title, boolean attachToInputContext)
Creates a top-level window for use by the input method.
void dispatchEvent(AWTEvent event)
Dispatches an event to the active input method.
void dispatchInputMethodEvent(int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition)
Creates an input method event from the arguments given and dispatches it to the client component.
void enableClientWindowNotification(InputMethod inputMethod, boolean enable)
AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, Attribute[] attributes)
Calls the current client component's implementation of getCommittedText.
int getCommittedTextLength()
Calls the current client component's implementation of getCommittedTextLength.
int getInsertPositionOffset()
Calls the current client component's implementation of getInsertPositionOffset.
TextHitInfo getLocationOffset(int x, int y)
Calls the current client component's implementation of getLocationOffset.
AttributedCharacterIterator getSelectedText(Attribute[] attributes)
Calls the current client component's implementation of getSelectedText.
Rectangle getTextLocation(TextHitInfo offset)
Calls the current client component's implementation of getTextLocation.
[Expand]
Inherited Methods
From class sun.awt.im.InputContext
From class java.awt.im.InputContext
From class java.lang.Object
From interface java.awt.event.ComponentListener
From interface java.awt.event.WindowListener
From interface java.awt.im.InputMethodRequests
From interface java.awt.im.spi.InputMethodContext

Public Constructors

public InputMethodContext ()

Constructs an InputMethodContext.

Public Methods

public AttributedCharacterIterator cancelLatestCommittedText (Attribute[] attributes)

Calls the current client component's implementation of cancelLatestCommittedText.

Parameters
attributes a list of attributes that the input method is interested in
Returns
  • the latest committed text, or null when the "Undo Commit" feature is not supported

public JFrame createInputMethodJFrame (String title, boolean attachToInputContext)

Creates a top-level Swing JFrame for use by the input method. The intended behavior of this window is:

  • it floats above all document windows and dialogs
  • it and all components that it contains do not receive the focus
  • it has lightweight decorations, such as a reduced drag region without title
However, the actual behavior with respect to these three items is platform dependent.

The title may or may not be displayed, depending on the actual type of window created.

If attachToInputContext is true, the new window will share the input context that corresponds to this input method context, so that events for components in the window are automatically dispatched to the input method. Also, when the window is opened using setVisible(true), the input context will prevent deactivate and activate calls to the input method that might otherwise be caused.

Input methods must call Window.dispose on the returned input method window when it is no longer needed.

Parameters
title the title to be displayed in the window's title bar, if there is such a title bar. A null value is treated as an empty string, "".
attachToInputContext whether this window should share the input context that corresponds to this input method context
Returns
  • a JFrame with special characteristics for use by input methods

public Window createInputMethodWindow (String title, boolean attachToInputContext)

Creates a top-level window for use by the input method. The intended behavior of this window is:

  • it floats above all document windows and dialogs
  • it and all components that it contains do not receive the focus
  • it has lightweight decorations, such as a reduced drag region without title
However, the actual behavior with respect to these three items is platform dependent.

The title may or may not be displayed, depending on the actual type of window created.

If attachToInputContext is true, the new window will share the input context that corresponds to this input method context, so that events for components in the window are automatically dispatched to the input method. Also, when the window is opened using setVisible(true), the input context will prevent deactivate and activate calls to the input method that might otherwise be caused.

Input methods must call Window.dispose on the returned input method window when it is no longer needed.

Parameters
title the title to be displayed in the window's title bar, if there is such a title bar. A null value is treated as an empty string, "".
attachToInputContext whether this window should share the input context that corresponds to this input method context
Returns
  • a window with special characteristics for use by input methods

public void dispatchEvent (AWTEvent event)

Dispatches an event to the active input method. Called by AWT. If no input method is available, then the event will never be consumed.

Parameters
event The event

public void dispatchInputMethodEvent (int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition)

Creates an input method event from the arguments given and dispatches it to the client component. For arguments, see InputMethodEvent(Component, int, long, AttributedCharacterIterator, int, TextHitInfo, TextHitInfo).

public void enableClientWindowNotification (InputMethod inputMethod, boolean enable)

public AttributedCharacterIterator getCommittedText (int beginIndex, int endIndex, Attribute[] attributes)

Calls the current client component's implementation of getCommittedText.

Parameters
beginIndex the index of the first character
endIndex the index of the character following the last character
attributes a list of attributes that the input method is interested in
Returns
  • an iterator providing access to the text and its attributes

public int getCommittedTextLength ()

Calls the current client component's implementation of getCommittedTextLength.

Returns
  • the length of the text except for uncommitted text

public int getInsertPositionOffset ()

Calls the current client component's implementation of getInsertPositionOffset.

Returns
  • the offset of the insert position

public TextHitInfo getLocationOffset (int x, int y)

Calls the current client component's implementation of getLocationOffset.

Parameters
x the absolute x coordinate on screen
y the absolute y coordinate on screen
Returns
  • a text hit info describing the offset in the composed text.

public AttributedCharacterIterator getSelectedText (Attribute[] attributes)

Calls the current client component's implementation of getSelectedText.

Parameters
attributes a list of attributes that the input method is interested in
Returns
  • the currently selected text

public Rectangle getTextLocation (TextHitInfo offset)

Calls the current client component's implementation of getTextLocation.

Parameters
offset the offset within the composed text, if there is composed text; null otherwise
Returns
  • a rectangle representing the screen location of the offset