java.awt.AWTEvent#getID ( )源码实例Demo

下面列出了java.awt.AWTEvent#getID ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hottub   文件: DitherTest.java
@Override
protected void processEvent(AWTEvent evt) {
    int id = evt.getID();
    if (id != KeyEvent.KEY_TYPED) {
        super.processEvent(evt);
        return;
    }

    KeyEvent kevt = (KeyEvent) evt;
    char c = kevt.getKeyChar();

    // Digits, backspace, and delete are okay
    // Note that the minus sign is not allowed (neither is decimal)
    if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
        super.processEvent(evt);
        return;
    }

    Toolkit.getDefaultToolkit().beep();
    kevt.consume();
}
 
源代码2 项目: openjdk-jdk8u-backup   文件: DitherTest.java
@Override
protected void processEvent(AWTEvent evt) {
    int id = evt.getID();
    if (id != KeyEvent.KEY_TYPED) {
        super.processEvent(evt);
        return;
    }

    KeyEvent kevt = (KeyEvent) evt;
    char c = kevt.getKeyChar();

    // Digits, backspace, and delete are okay
    // Note that the minus sign is not allowed (neither is decimal)
    if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
        super.processEvent(evt);
        return;
    }

    Toolkit.getDefaultToolkit().beep();
    kevt.consume();
}
 
源代码3 项目: jdk8u-jdk   文件: DitherTest.java
@Override
protected void processEvent(AWTEvent evt) {
    int id = evt.getID();
    if (id != KeyEvent.KEY_TYPED) {
        super.processEvent(evt);
        return;
    }

    KeyEvent kevt = (KeyEvent) evt;
    char c = kevt.getKeyChar();

    // Digits, backspace, and delete are okay
    // Note that the minus sign is not allowed (neither is decimal)
    if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
        super.processEvent(evt);
        return;
    }

    Toolkit.getDefaultToolkit().beep();
    kevt.consume();
}
 
源代码4 项目: jdk8u_jdk   文件: AppletFrame.java
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
public boolean dispatchEvent(AWTEvent e) {
    if (e.getID() == FocusEvent.FOCUS_GAINED) {
        System.out.println(e);
        Component src = (Component)e.getSource();
        if (src == frame.b1 || src == frame.b2) {
            throw new TestFailedException("wrong focus transfer on removal!");
        }
    }
    return super.dispatchEvent(e);
}
 
源代码6 项目: netbeans   文件: NbClipboard.java
@Override
public void eventDispatched(AWTEvent ev) {
    if (!(ev instanceof WindowEvent))
        return;

    if (ev.getID() == WindowEvent.WINDOW_DEACTIVATED) {
        lastWindowDeactivated = System.currentTimeMillis();
        lastWindowDeactivatedSource = new WeakReference<Object>(ev.getSource());
        anyWindowIsActivated = false;
        if( Utilities.isWindows() ) {
            //#247585 - even listening to clipboard changes when the window isn't active 
            //may throw a MS Windows error as the 'clipboard copy' action doesn't have enough time to finish
            systemClipboard.removeFlavorListener(this);
        }
    }
    if (ev.getID() == WindowEvent.WINDOW_ACTIVATED) {
        if( Utilities.isWindows() ) {
            systemClipboard.addFlavorListener(this);
        }
        anyWindowIsActivated = true;
        if (System.currentTimeMillis() - lastWindowDeactivated < 100 &&
            ev.getSource() == lastWindowDeactivatedSource.get()) {
            activateWindowHack (false);
        }
        if (log.isLoggable (Level.FINE)) {
            log.log (Level.FINE, "window activated scheduling update"); // NOI18N
        }
        scheduleGetFromSystemClipboard(true);
    }
}
 
源代码7 项目: jdk8u-jdk   文件: XComponentPeer.java
void handleJavaFocusEvent(AWTEvent e) {
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer(e.toString());
    }
    if (e.getID() == FocusEvent.FOCUS_GAINED) {
        focusGained((FocusEvent)e);
    } else {
        focusLost((FocusEvent)e);
    }
}
 
源代码8 项目: marathonv5   文件: RComponent.java
public void handleRawRecording(IJSONRecorder recorder, AWTEvent event) {
    if (event instanceof MouseEvent && event.getID() == MouseEvent.MOUSE_PRESSED) {
        recorder.recordRawMouseEvent(this, (MouseEvent) event);
    }
    if (event instanceof KeyEvent && event.getID() != KeyEvent.KEY_RELEASED) {
        recorder.recordRawKeyEvent(this, (KeyEvent) event);
    }
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: TracedEventQueue.java
public void postEvent(AWTEvent theEvent) {
    boolean printEvent = true;
    int id = theEvent.getID();
    for (int i = 0; i < suppressedIDs.length; i++) {
        if (id == suppressedIDs[i]) {
            printEvent = false;
            break;
        }
    }
    if (printEvent) {
        System.out.println(Thread.currentThread().getName() +
                           ": " + theEvent);
    }
    super.postEvent(theEvent);
}
 
public boolean dispatchEvent(AWTEvent e) {
    if (e.getID() == FocusEvent.FOCUS_GAINED) {
        System.out.println(e);
        Component src = (Component)e.getSource();
        if (src == frame.b1 || src == frame.b2) {
            throw new TestFailedException("wrong focus transfer on removal!");
        }
    }
    return super.dispatchEvent(e);
}
 
源代码11 项目: visualvm   文件: DropdownButton.java
private void processEventImpl(AWTEvent e) {
    super.processEvent(e);
    if (e.getID() == MouseEvent.MOUSE_PRESSED) {
        if (isFocusable()) requestFocus();
        else button.requestFocus();
    }
}
 
源代码12 项目: hottub   文件: TracedEventQueue.java
public void postEvent(AWTEvent theEvent) {
    boolean printEvent = true;
    int id = theEvent.getID();
    for (int i = 0; i < suppressedIDs.length; i++) {
        if (id == suppressedIDs[i]) {
            printEvent = false;
            break;
        }
    }
    if (printEvent) {
        System.out.println(Thread.currentThread().getName() +
                           ": " + theEvent);
    }
    super.postEvent(theEvent);
}
 
源代码13 项目: jdk8u_jdk   文件: XComponentPeer.java
void handleJavaFocusEvent(AWTEvent e) {
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer(e.toString());
    }
    if (e.getID() == FocusEvent.FOCUS_GAINED) {
        focusGained((FocusEvent)e);
    } else {
        focusLost((FocusEvent)e);
    }
}
 
源代码14 项目: jdk8u-jdk   文件: TracedEventQueue.java
public void postEvent(AWTEvent theEvent) {
    boolean printEvent = true;
    int id = theEvent.getID();
    for (int i = 0; i < suppressedIDs.length; i++) {
        if (id == suppressedIDs[i]) {
            printEvent = false;
            break;
        }
    }
    if (printEvent) {
        System.out.println(Thread.currentThread().getName() +
                           ": " + theEvent);
    }
    super.postEvent(theEvent);
}
 
源代码15 项目: openjdk-jdk8u   文件: CodePointInputMethod.java
/**
 * This is the input method's main routine.  The composed text is stored
 * in buffer.
 */
public void dispatchEvent(AWTEvent event) {
    // This input method handles KeyEvent only.
    if (!(event instanceof KeyEvent)) {
        return;
    }

    KeyEvent e = (KeyEvent) event;
    int eventID = event.getID();
    boolean notInCompositionMode = buffer.length() == 0;

    if (eventID == KeyEvent.KEY_PRESSED) {
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }

        switch (e.getKeyCode()) {
            case KeyEvent.VK_LEFT:
                moveCaretLeft();
                break;
            case KeyEvent.VK_RIGHT:
                moveCaretRight();
                break;
        }
    } else if (eventID == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();

        // If we are not in composition mode, wait a back slash
        if (notInCompositionMode) {
            // If the type character is not a back slash, pass through
            if (c != '\\') {
                return;
            }

            startComposition();     // Enter to composition mode
        } else {
            switch (c) {
                case ' ':       // Exit from composition mode
                    finishComposition();
                    break;
                case '\u007f':  // Delete
                    deleteCharacter();
                    break;
                case '\b':      // BackSpace
                    deletePreviousCharacter();
                    break;
                case '\u001b':  // Escape
                    cancelComposition();
                    break;
                case '\n':      // Return
                case '\t':      // Tab
                    sendCommittedText();
                    break;
                default:
                    composeUnicodeEscape(c);
                    break;
            }
        }
    } else {  // KeyEvent.KEY_RELEASED
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }
    }

    e.consume();
}
 
源代码16 项目: dragonwell8_jdk   文件: CodePointInputMethod.java
/**
 * This is the input method's main routine.  The composed text is stored
 * in buffer.
 */
public void dispatchEvent(AWTEvent event) {
    // This input method handles KeyEvent only.
    if (!(event instanceof KeyEvent)) {
        return;
    }

    KeyEvent e = (KeyEvent) event;
    int eventID = event.getID();
    boolean notInCompositionMode = buffer.length() == 0;

    if (eventID == KeyEvent.KEY_PRESSED) {
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }

        switch (e.getKeyCode()) {
            case KeyEvent.VK_LEFT:
                moveCaretLeft();
                break;
            case KeyEvent.VK_RIGHT:
                moveCaretRight();
                break;
        }
    } else if (eventID == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();

        // If we are not in composition mode, wait a back slash
        if (notInCompositionMode) {
            // If the type character is not a back slash, pass through
            if (c != '\\') {
                return;
            }

            startComposition();     // Enter to composition mode
        } else {
            switch (c) {
                case ' ':       // Exit from composition mode
                    finishComposition();
                    break;
                case '\u007f':  // Delete
                    deleteCharacter();
                    break;
                case '\b':      // BackSpace
                    deletePreviousCharacter();
                    break;
                case '\u001b':  // Escape
                    cancelComposition();
                    break;
                case '\n':      // Return
                case '\t':      // Tab
                    sendCommittedText();
                    break;
                default:
                    composeUnicodeEscape(c);
                    break;
            }
        }
    } else {  // KeyEvent.KEY_RELEASED
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }
    }

    e.consume();
}
 
源代码17 项目: hottub   文件: InputContext.java
/**
 * @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);
        }
    }
}
 
源代码18 项目: jdk8u_jdk   文件: InputContext.java
/**
 * @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);
        }
    }
}
 
源代码19 项目: jdk8u-dev-jdk   文件: CodePointInputMethod.java
/**
 * This is the input method's main routine.  The composed text is stored
 * in buffer.
 */
public void dispatchEvent(AWTEvent event) {
    // This input method handles KeyEvent only.
    if (!(event instanceof KeyEvent)) {
        return;
    }

    KeyEvent e = (KeyEvent) event;
    int eventID = event.getID();
    boolean notInCompositionMode = buffer.length() == 0;

    if (eventID == KeyEvent.KEY_PRESSED) {
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }

        switch (e.getKeyCode()) {
            case KeyEvent.VK_LEFT:
                moveCaretLeft();
                break;
            case KeyEvent.VK_RIGHT:
                moveCaretRight();
                break;
        }
    } else if (eventID == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();

        // If we are not in composition mode, wait a back slash
        if (notInCompositionMode) {
            // If the type character is not a back slash, pass through
            if (c != '\\') {
                return;
            }

            startComposition();     // Enter to composition mode
        } else {
            switch (c) {
                case ' ':       // Exit from composition mode
                    finishComposition();
                    break;
                case '\u007f':  // Delete
                    deleteCharacter();
                    break;
                case '\b':      // BackSpace
                    deletePreviousCharacter();
                    break;
                case '\u001b':  // Escape
                    cancelComposition();
                    break;
                case '\n':      // Return
                case '\t':      // Tab
                    sendCommittedText();
                    break;
                default:
                    composeUnicodeEscape(c);
                    break;
            }
        }
    } else {  // KeyEvent.KEY_RELEASED
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }
    }

    e.consume();
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: InputContext.java
/**
 * @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);
        }
    }
}
 
 方法所在类
 同类方法