当前位置: 首页>>代码示例>>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;未经允许,请勿转载。