Java Code Examples for java.awt.Component#getInputContext()

The following examples show how to use java.awt.Component#getInputContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputContext.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 2
Source File: InputContext.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 3
Source File: InputContext.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 4
Source File: InputContext.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 5
Source File: InputContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 6
Source File: InputContext.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 7
Source File: InputContext.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 8
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 9
Source File: InputContext.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 10
Source File: InputContext.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 11
Source File: InputContext.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 12
Source File: InputContext.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 13
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 14
Source File: InputContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}