| Documentation Contents

# Input Method Framework Demo

alt="Applet that shows different ways of interacting with input methods"

This applet contains four text components that show the different ways of interacting with input methods in the Java 2 platform. This applet can be run in two ways:

- with an implementation of the Java 2 Platform Standard Edition v1.2 or higher, running on a platform/locale that uses native input methods. Examples: Japanese Windows NT, Macintosh with Chinese Language Kit, Solaris with Korean locale.
- with an implementation of the Java 2 Platform Standard Edition v1.3 or higher, with an input method installed that's implemented in the Java programming language. The Java runtime environment may be running on a platform/locale that does not support native input methods.

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 active client uses the input method framework API to implement on-the-spot (also called "inline") text composition.
- 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 non-client refuses to work with input methods.

To test with the different components with native Japanese 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:

- Active client: The word is entered in in the component directly and gets converted to four hiragana characters as you type.
- Passive client: A separate window shows up, the word is entered in that window and gets converted to four hiragana characters as you type.
- Non-client: The text "nihongo" is entered into the component.
- 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 or Space 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.

To test with the different components with the sample input method implemented in the Java programming language, "City Input Method", install the input method's JAR file into the extensions directory of the Java runtime environment before running the applet. Then click into the components to focus on them, and select the input method. The selection mechanism is implementation dependent; on Sun's Java runtime environments choose the "Select Input Method" menu item from the system menu in the top left corner of the window, then choose the input method from the pop-up menu that comes up. Then type "TYO". The behavior you should see:

- Active client: The text is entered in the component directly and is highlighted.
- Passive client: A separate window shows up, the text is entered in that window and is highlighted.
- Non-client: The text is entered into the component, but not highlighted.
- Peered component: The behavior depends on the platform.

For all components except the non-client and, on some platforms, the peered component, you can now convert the text using the Space key. The conversion result depends on your default language - it's the name "Tokyo" in Japanese, Japanese yomi, English, German, simplified or traditional Chinese. To see all options, press Space again - this time, you'll get a look-up window showing all the possibilities. You can use Space to go through all possible selections, or type the number of the conversion you like. Pressing the Enter key will commit the selected conversion and remove the highlight.

Copyright © 1995-2010 Sun Microsystems, Inc. All Rights Reserved. Please send comments using this Feedback page. | Java Technology