|
|||||||||
| Home >> All >> java >> awt >> [ im overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.awt.im
Class InputContext

java.lang.Objectjava.awt.im.InputContext
- public class InputContext
- extends java.lang.Object
Provides a context for controlling input methods and keyboard layouts. This class provides the communication layer between the client component, and the various locale-dependent text entry input methods that can be used for the client. By default, there is one instance per Window, shared among all components, but this limits text entry to one component at a time. Thus, text components can create their own instance to allow text entry in multiple components at a time.
By using the interfaces of java.awt.im.spi, you can install
extensions which allow additional input methods. Some of these may use
platform native input methods, or keyboard layouts provided by the platform.
Input methods are unavailable if none have been installed and the platform
has no underlying native input methods. Extensions are installed as jar
files, usually accessed in the default extension location or specified by
the -extdir VM flag. The jar must contain a file named
"META_INF/services/java.awt.im.spi.InputMethodDescriptor" which lists,
one entry per line in UTF-8 encoding, each class in the jar that implements
java.awt.im.spi.InputMethodDescriptor.
- Since:
- 1.2
| Field Summary | |
private static java.util.ArrayList |
descriptors
The list of installed input method descriptors. |
private java.awt.im.spi.InputMethod |
im
The current input method; null if no input methods are installed. |
private java.util.HashMap |
recent
Map of locales to the most recently selected input method. |
private java.lang.Character.Subset[] |
subsets
The list of acceptable character subsets. |
| Constructor Summary | |
protected |
InputContext()
Construct an InputContext. |
| Method Summary | |
void |
dispatchEvent(java.awt.AWTEvent event)
Dispatches an event to the current input method. |
void |
dispose()
Disposes of the input context and release the resources used by it. |
void |
endComposition()
Ends any input composition that may currently be going on in this context. |
java.lang.Object |
getInputMethodControlObject()
Returns a control object from the current input method, or null. |
static InputContext |
getInstance()
Returns a new InputContext. |
java.util.Locale |
getLocale()
Returns the current locale of the current input method or keyboard layout. |
boolean |
isCompositionEnabled()
Find out if the current input method is enabled. |
void |
reconvert()
Starts a reconversion operation in the current input method. |
void |
removeNotify(java.awt.Component client)
Notifies the input context that a client component has been removed from its containment hierarchy, or that input method support has been disabled for the component. |
boolean |
selectInputMethod(java.util.Locale locale)
Attempts to select an input method or keyboard layout which supports the given locale. |
void |
setCharacterSubsets(java.lang.Character.Subset[] subsets)
Sets the subsets of Unicode characters allowed to be input by the current input method, as well as subsequent input methods. |
void |
setCompositionEnabled(boolean enable)
Changes the enabled status of the current input method. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
descriptors
private static final java.util.ArrayList descriptors
- The list of installed input method descriptors.
im
private java.awt.im.spi.InputMethod im
- The current input method; null if no input methods are installed.
recent
private final java.util.HashMap recent
- Map of locales to the most recently selected input method.
subsets
private java.lang.Character.Subset[] subsets
- The list of acceptable character subsets.
| Constructor Detail |
InputContext
protected InputContext()
- Construct an InputContext. This is protected, so clients must use
getInstance()55 instead.
| Method Detail |
getInstance
public static InputContext getInstance()
- Returns a new InputContext.
selectInputMethod
public boolean selectInputMethod(java.util.Locale locale)
- Attempts to select an input method or keyboard layout which supports the
given locale. This returns true if a locale is available and was selected.
The following steps are taken in choosing an input method:
- If the currently selected input method or keyboard layout supports the requested locale, it remains selected.
- If there is no input method or keyboard layout available that supports the requested locale, the current input method or keyboard layout remains selected.
- If the user has previously selected an input method or keyboard layout for the requested locale from the user interface, then the most recently selected such input method or keyboard layout is reselected.
- Otherwise, an input method or keyboard layout that supports the requested locale is selected in an implementation dependent way. This implementation chooses the first input method which supports the requested locale based on the InputMethodDescriptors loaded from the extensions installed on the CLASSPATH.
Before switching away from an input method, any currently uncommitted text is committed. Not all host operating systems provide API to determine the locale of the currently selected native input method or keyboard layout, and to select a native input method or keyboard layout by locale. For host operating systems that don't provide such API, selectInputMethod assumes that native input methods or keyboard layouts provided by the host operating system support only the system's default locale.
An example of where this may be called is in a multi-language document, when moving the insertion point between sections of different locale, so that the user may use the input method appropriate to that section of the document.
getLocale
public java.util.Locale getLocale()
- Returns the current locale of the current input method or keyboard
layout. Returns null if the input context does not have a current input
method or keyboard layout or if the current input method's
InputMethod.getLocale()>
InputMethod.getLocale()55 method returns null. Not all host operating systems provide API to determine the locale of the currently selected native input method or keyboard layout. For host operating systems that don't provide such API, getLocale assumes that the current locale of all native input methods or keyboard layouts provided by the host operating system is the system's default locale.- Since:
- 1.3
setCharacterSubsets
public void setCharacterSubsets(java.lang.Character.Subset[] subsets)
- Sets the subsets of Unicode characters allowed to be input by the current
input method, as well as subsequent input methods. The value of null
implies all characters are legal. Applications should not rely on this
behavior, since native host input methods may not allow restrictions.
If no current input method is available, this has no immediate effect.
setCompositionEnabled
public void setCompositionEnabled(boolean enable)
- Changes the enabled status of the current input method. An input method
that is enabled for composition interprets incoming events for both
composition and control purposes, while a disabled input method only
interprets control commands (including commands to enable itself).
- Since:
- 1.3
isCompositionEnabled
public boolean isCompositionEnabled()
- Find out if the current input method is enabled.
- Since:
- 1.3
reconvert
public void reconvert()
- Starts a reconversion operation in the current input method. The input
method gets the text to reconvert from the client component, using
InputMethodRequests#getSelectedText(Attribute[]). Then the composed and committed text produced by the operation is sent back to the client using a sequence of InputMethodRequests.- Since:
- 1.3
dispatchEvent
public void dispatchEvent(java.awt.AWTEvent event)
- Dispatches an event to the current input method. This is called
automatically by AWT. If no input method is available, then the event
will never be consumed.
removeNotify
public void removeNotify(java.awt.Component client)
- Notifies the input context that a client component has been removed from
its containment hierarchy, or that input method support has been disabled
for the component. This method is usually called from the client
component's Component.removeNotify()>
Component.removeNotify()55 method. Potentially pending input from input methods for this component is discarded. If no input methods are available, then this method has no effect.
endComposition
public void endComposition()
- Ends any input composition that may currently be going on in this
context. Depending on the platform and possibly user preferences, this
may commit or delete uncommitted text. Any changes to the text are
communicated to the active component using an input method event. If no
input methods are available, then this method has no effect. This may
be called for a variety of reasons, such as when the user moves the
insertion point in the client text outside the range of the composed text,
or when text is saved to file.
dispose
public void dispose()
- Disposes of the input context and release the resources used by it.
Called automatically by AWT for the default input context of each
Window. If no input methods are available, then this method has no
effect.
getInputMethodControlObject
public java.lang.Object getInputMethodControlObject()
- Returns a control object from the current input method, or null. A
control object provides implementation-dependent methods that control
the behavior of the input method or obtain information from the input
method. Clients have to compare the result against known input method
control object types. If no input methods are available or the current
input method does not provide an input method control object, then null
is returned.
|
|||||||||
| Home >> All >> java >> awt >> [ im overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.awt.im.InputContext