类java.awt.event.InputMethodEvent源码实例Demo

下面列出了怎么用java.awt.event.InputMethodEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-jdk   文件: X11InputMethod.java
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
源代码2 项目: jdk8u-jdk   文件: CodePointInputMethod.java
/**
 * Move the insertion point one position to the left in the composed text.
 * Do not let the caret move to the left of the "\\u" or "\\U".
 */
private void moveCaretLeft() {
    int len = buffer.length();
    if (--insertionPoint < 2) {
        insertionPoint++;
        beep();
    } else if (format == SURROGATE_PAIR && insertionPoint == 7) {
        insertionPoint = 8;
        beep();
    }

    context.dispatchInputMethodEvent(
            InputMethodEvent.CARET_POSITION_CHANGED,
            null, 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码3 项目: jdk8u-jdk   文件: CodePointInputMethod.java
/**
 * Move the insertion point one position to the left in the composed text.
 * Do not let the caret move to the left of the "\\u" or "\\U".
 */
private void moveCaretLeft() {
    int len = buffer.length();
    if (--insertionPoint < 2) {
        insertionPoint++;
        beep();
    } else if (format == SURROGATE_PAIR && insertionPoint == 7) {
        insertionPoint = 8;
        beep();
    }

    context.dispatchInputMethodEvent(
            InputMethodEvent.CARET_POSITION_CHANGED,
            null, 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码4 项目: hottub   文件: X11InputMethod.java
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: InputMethodContext.java
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
源代码6 项目: TencentKona-8   文件: InputMethodContext.java
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
源代码7 项目: TencentKona-8   文件: InputMethodContext.java
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
源代码8 项目: hottub   文件: InputMethodContext.java
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
源代码9 项目: openjdk-jdk9   文件: X11InputMethod.java
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
源代码10 项目: openjdk-8   文件: X11InputMethod.java
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
源代码11 项目: openjdk-jdk9   文件: InputMethodContext.java
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
源代码12 项目: hottub   文件: X11InputMethod.java
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
源代码13 项目: jdk8u-jdk   文件: X11InputMethod.java
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
源代码14 项目: jdk8u-dev-jdk   文件: X11InputMethod.java
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
源代码15 项目: jdk8u60   文件: InputMethodContext.java
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
源代码16 项目: jdk8u60   文件: X11InputMethod.java
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
源代码17 项目: openjdk-jdk8u   文件: InputMethodContext.java
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
源代码18 项目: dragonwell8_jdk   文件: CodePointInputMethod.java
/**
 * Send the composed text to the client.
 */
private void sendComposedText() {
    AttributedString as = new AttributedString(buffer.toString());
    as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT,
            InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT);
    context.dispatchInputMethodEvent(
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            as.getIterator(), 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码19 项目: dragonwell8_jdk   文件: CodePointInputMethod.java
/**
 * Move the insertion point one position to the right in the composed text.
 */
private void moveCaretRight() {
    int len = buffer.length();
    if (++insertionPoint > len) {
        insertionPoint = len;
        beep();
    }

    context.dispatchInputMethodEvent(
            InputMethodEvent.CARET_POSITION_CHANGED,
            null, 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码20 项目: jdk8u-jdk   文件: CodePointInputMethod.java
/**
 * Move the insertion point one position to the right in the composed text.
 */
private void moveCaretRight() {
    int len = buffer.length();
    if (++insertionPoint > len) {
        insertionPoint = len;
        beep();
    }

    context.dispatchInputMethodEvent(
            InputMethodEvent.CARET_POSITION_CHANGED,
            null, 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码21 项目: dragonwell8_jdk   文件: CompositionAreaHandler.java
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
源代码22 项目: Bytecoder   文件: CompositionAreaHandler.java
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
源代码23 项目: openjdk-8-source   文件: CodePointInputMethod.java
/**
 * Send the composed text to the client.
 */
private void sendComposedText() {
    AttributedString as = new AttributedString(buffer.toString());
    as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT,
            InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT);
    context.dispatchInputMethodEvent(
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            as.getIterator(), 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码24 项目: openjdk-8-source   文件: bug6636983.java
void sendInputMethodEvent() {
    InputMethodEvent ime = new InputMethodEvent(
            ep,
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            Hiragana_A.getIterator(),
            0,
            null,
            null);
    ep.dispatchEvent(ime);
}
 
源代码25 项目: openjdk-jdk9   文件: CompositionAreaHandler.java
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
源代码26 项目: jdk8u_jdk   文件: CodePointInputMethod.java
/**
 * Move the insertion point one position to the right in the composed text.
 */
private void moveCaretRight() {
    int len = buffer.length();
    if (++insertionPoint > len) {
        insertionPoint = len;
        beep();
    }

    context.dispatchInputMethodEvent(
            InputMethodEvent.CARET_POSITION_CHANGED,
            null, 0,
            TextHitInfo.leading(insertionPoint), null);
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: bug6636983.java
void sendInputMethodEvent() {
    InputMethodEvent ime = new InputMethodEvent(
            ep,
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            Hiragana_A.getIterator(),
            0,
            null,
            null);
    ep.dispatchEvent(ime);
}
 
源代码28 项目: jdk8u_jdk   文件: bug6636983.java
void sendInputMethodEvent() {
    InputMethodEvent ime = new InputMethodEvent(
            ep,
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            Hiragana_A.getIterator(),
            0,
            null,
            null);
    ep.dispatchEvent(ime);
}
 
源代码29 项目: jdk8u_jdk   文件: CompositionAreaHandler.java
public void caretPositionChanged(InputMethodEvent event) {
    if (compositionArea != null) {
        compositionArea.setCaret(event.getCaret());
    }

    // event has been handled, so consume it
    event.consume();
}
 
源代码30 项目: jdk8u60   文件: CodePointInputMethod.java
/**
 * Send the committed text to the client.
 */
private void sendCommittedText() {
    AttributedString as = new AttributedString(buffer.toString());
    context.dispatchInputMethodEvent(
            InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
            as.getIterator(), buffer.length(),
            TextHitInfo.leading(insertionPoint), null);

    buffer.setLength(0);
    insertionPoint = 0;
    format = UNSET;
}