當前位置: 首頁>>代碼示例>>Java>>正文


Java AWTEvent.getID方法代碼示例

本文整理匯總了Java中java.awt.AWTEvent.getID方法的典型用法代碼示例。如果您正苦於以下問題:Java AWTEvent.getID方法的具體用法?Java AWTEvent.getID怎麽用?Java AWTEvent.getID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.AWTEvent的用法示例。


在下文中一共展示了AWTEvent.getID方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
@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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:DitherTest.java

示例2: eventDispatched

import java.awt.AWTEvent; //導入方法依賴的package包/類
@Override public void eventDispatched(AWTEvent event) {
    if (ignoreMouseEvents) {
        return;
    }
    Component root = SwingUtilities.getRoot((Component) event.getSource());
    if (root instanceof IRecordingArtifact || root.getName().startsWith("###")) {
        return;
    }
    if (!(event instanceof MouseEvent)) {
        return;
    }
    MouseEvent mouseEvent = (MouseEvent) event;
    mouseEvent.consume();
    if (event.getID() == MouseEvent.MOUSE_PRESSED) {
        disposeOverlay();
        Component mouseComponent = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(),
                mouseEvent.getY());
        if (mouseComponent == null) {
            return;
        }
        mouseEvent = SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, mouseComponent);
        setComponent(mouseComponent, mouseEvent.getPoint(), true);
        return;
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:26,代碼來源:ContextMenuWindow.java

示例3: eventDispatched

import java.awt.AWTEvent; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:NbClipboard.java

示例4: handleJavaFocusEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:XComponentPeer.java

示例5: postEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:16,代碼來源:TracedEventQueue.java

示例6: dispatchEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:ContainerFocusAutoTransferTest.java

示例7: processEventImpl

import java.awt.AWTEvent; //導入方法依賴的package包/類
private void processEventImpl(AWTEvent e) {
    super.processEvent(e);
    if (e.getID() == MouseEvent.MOUSE_PRESSED) {
        if (isFocusable()) requestFocus();
        else button.requestFocus();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:DropdownButton.java

示例8: processEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
@Override
public void processEvent(AWTEvent e) {
    // Window Destroy event
    if (e.getID() == Event.WINDOW_DESTROY) {
        // exit the program
        System.exit(0);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:AppletFrame.java

示例9: eventDispatched

import java.awt.AWTEvent; //導入方法依賴的package包/類
@Override
public void eventDispatched(AWTEvent event) {
    if (event.getID() == MouseEvent.MOUSE_PRESSED || event.getID() == KeyEvent.KEY_PRESSED) {
        onClick(event);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:TooltipWindow.java

示例10: eventDispatched

import java.awt.AWTEvent; //導入方法依賴的package包/類
public void eventDispatched(AWTEvent event) {
    if (event.getID() == MouseEvent.MOUSE_PRESSED || event.getID() == KeyEvent.KEY_PRESSED) {
        onClick(event);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:TooltipWindow.java

示例11: eventDispatched

import java.awt.AWTEvent; //導入方法依賴的package包/類
@Override
public void eventDispatched( AWTEvent e ) {
    if( !(e instanceof KeyEvent) )
        return;
    KeyEvent ke = ( KeyEvent ) e;
    ke.consume();
    
    if( e.getID() == KeyEvent.KEY_PRESSED ) {

        switch( ke.getKeyCode() ) {
            case KeyEvent.VK_LEFT:
                do {
                    currentSide = currentSide.moveLeft();
                } while( !checkDropLocation() );
                refresh();
                break;
            case KeyEvent.VK_RIGHT:
                do {
                    currentSide = currentSide.moveRight();
                } while( !checkDropLocation() );
                refresh();
                break;
            case KeyEvent.VK_UP:
                do {
                    currentSide = currentSide.moveUp();
                } while( !checkDropLocation() );
                refresh();
                break;
            case KeyEvent.VK_DOWN:
                do {
                    currentSide = currentSide.moveDown();
                } while( !checkDropLocation() );
                refresh();
                break;
            case KeyEvent.VK_ENTER:
                stop( true );
                break;
            case KeyEvent.VK_ESCAPE:
                abort();
                break;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:KeyboardDnd.java

示例12: dispatchEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
/**
 * @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);
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:49,代碼來源:InputContext.java

示例13: dispatchEvent

import java.awt.AWTEvent; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:72,代碼來源:CodePointInputMethod.java


注:本文中的java.awt.AWTEvent.getID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。