当前页面:
在线文档首页 >
JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档
Input Method Framework Demo - JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档
Input Method Framework Demo
This applet contains four text components that show the different ways of
interacting with input methods in JDK 1.2. This applet should be run on a
platform/locale that uses input methods, e.g., Japanese Windows NT, Macintosh
with Chinese Language Kit, Solaris with Korean locale. It requires JDK 1.2
or higher.
The first three components are lightweight components, i.e., they handle events
and render text using Java APIs. The last one is a peered component, that is,
event handling and text rendering are handled by a text editing engine provided
by the underlying platform. Peered components were used widely in JDK 1.0 AWT,
while lightweight components were introduced in JDK 1.1 and are the basis of
the Swing class library.
The lightweight components have different capabilities:
- The non-client refuses to work with input methods.
- The passive client works with input methods in the simplest way - it relies
on the input method framework to handle all composition and only accepts
committed text.
- The active client uses the input method framework API to implement
on-the-spot (also called "inline") text composition.
To test with the different components with Japanese (using the platform's
default input methods), click into the components to focus on them, turn
on an input method (Alt-` on Windows, choosing from the keyboard menu on
Macintosh, Control-Space on Solaris), then type "nihongo". The behavior you
should see is:
- Non-client: The text "nihongo" is entered into the component.
- Passive client: A separate window shows up, the word is entered in that
window and gets converted to four hiragana characters as you type.
- Active client: The word is entered in in the component directly and gets
converted to four hiragana characters as you type.
- Peered component: The behavior depends on the platform, but most likely
it's similar to the active client (the text may be drawn over the pre-existing
text or push it to the right).
For all components except the non-client, you can now convert the text (Space on
Windows and Macintosh, Control-N on Solaris) and then commit it
(Enter on all three platforms - how could that happen?). Conversion should result
in three kanji characters, which after committing are shown in the component
without highlight.