⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputmethodhandler.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
字号:
/* * @(#)InputMethodHandler.java	1.12 01/08/21 * * Copyright (c) 2000-2001 Sun Microsystems, Inc., 901 San Antonio Road, * Palo Alto, CA 94303, U.S.A.  All Rights Reserved. * * Sun Microsystems, Inc. has intellectual property rights relating * to the technology embodied in this software.  In particular, and * without limitation, these intellectual property rights may include * one or more U.S. patents, foreign patents, or pending * applications.  Sun, Sun Microsystems, the Sun logo, Java, KJava, * and all Sun-based and Java-based marks are trademarks or * registered trademarks of Sun Microsystems, Inc.  in the United * States and other countries. * * This software is distributed under licenses restricting its use, * copying, distribution, and decompilation.  No part of this * software may be reproduced in any form by any means without prior * written authorization of Sun and its licensors, if any. * * FEDERAL ACQUISITIONS:  Commercial Software -- Government Users * Subject to Standard License Terms and Conditions */package com.sun.midp.lcdui;import javax.microedition.lcdui.TextBox;import javax.microedition.lcdui.TextField;import com.sun.midp.Configuration;/** * The InputMethod handler. */abstract public class InputMethodHandler {    /** handle for the current input method handler. */    private static InputMethodHandler thisIM;    /**     * get the input method handler.     * @return the current input method handler.     */    public static InputMethodHandler getInputMethodHandler() {        if (thisIM != null) {            return thisIM;        }        thisIM = getInputMethodHandlerImpl();        return thisIM;    }    /**     * get the input handler class.     * @return handle to input method handlet.     */    private static InputMethodHandler getInputMethodHandlerImpl() {        try {            String n =		Configuration.getProperty("com.sun.lcdui.inputMethodHandler");            if (n != null) {                Class c = Class.forName(n);                return (InputMethodHandler) c.newInstance();            }            String loc = Configuration.getProperty("microedition.locale");            if (loc != null) {                String cls                    = "com.sun.midp.lcdui.i18n.DefaultInputMethodHandler_";                while (true) {                    try {                        Class c = Class.forName(cls + loc);                        return (InputMethodHandler) c.newInstance();                    } catch (Throwable t) {}                    int pos = loc.lastIndexOf('_');                    if (pos == -1) {                        break;                    } else {                        loc = loc.substring(0, pos);                    }                }            }            Class c =                 Class.forName("com.sun.midp.lcdui.DefaultInputMethodHandler");            return (InputMethodHandler) c.newInstance();        } catch (Throwable t) {                        System.out.println(t);          	    throw new Error("Textbox input method was not initialized.");        }    }    /**     * Set the focus on the InputMethod.     * @param focus true, if now in focus.     */    public abstract void setFocus(boolean focus);    /**     * Set the InputMethodClient object to the InputMethod.     * @param imc save the current input method client.     */    public abstract void setInputMethodClient(InputMethodClient imc);    /**     * Clear the given InputMethodClient object, so it can be garbage     * collected. Do nothing if the given client is not the one set.     * @param  imcToBeCleared input method client to be cleared.     */    public abstract void clearInputMethodClient(InputMethodClient                                                 imcToBeCleared);    /**     * Called when a key is pressed.     * @param keyCode The key code of the key that was pressed     * @return true if the InputMethod consumed the     * key code.       */    public abstract boolean keyPressed(int keyCode);    /**     * Called when a key is released.     * @param keyCode The key code of the key that was released     * @return true if the InputMethod consumed the     * key code.       */    public abstract boolean keyReleased(int keyCode);    /**     * Called when a key is repeated.     * @param keyCode The key code of the key that was repeated     * @return true if the InputMethod consumed the     * key code.       */    public abstract boolean keyRepeated(int keyCode);    /**     * End the on-going composition.     */    public abstract void endComposition();    /**     * Return the supported input modes.     * @return array of strings of supported input modes.     */    public abstract String[] supportedInputModes();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -