当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.KEY_PRESSED属性代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.KEY_PRESSED属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEY_PRESSED属性的具体用法?Java KeyEvent.KEY_PRESSED怎么用?Java KeyEvent.KEY_PRESSED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEY_PRESSED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleShortcut

@SuppressWarnings("deprecation")
boolean handleShortcut(KeyEvent e) {
    MenuShortcut s = new MenuShortcut(e.getKeyCode(),
                         (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
    MenuShortcut sE = new MenuShortcut(e.getExtendedKeyCode(),
                         (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
    // Fix For 6185151: Menu shortcuts of all menuitems within a menu
    // should be disabled when the menu itself is disabled
    if ((s.equals(shortcut) || sE.equals(shortcut)) && isItemEnabled()) {
        // MenuShortcut match -- issue an event on keydown.
        if (e.getID() == KeyEvent.KEY_PRESSED) {
            doMenuEvent(e.getWhen(), e.getModifiers());
        } else {
            // silently eat key release.
        }
        return true;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:MenuItem.java

示例2: dispatchKeyGeneral

/**
 * Handles the keys which have the same functionality for all the types
 * of labeling.
 */
private void dispatchKeyGeneral(KeyEvent e) {
    int eventId = e.getID();
    int key = e.getKeyCode();

    // the mapping of the keys is based on the default assignment of keys  for UGEE graphic tablet
    if (eventId == KeyEvent.KEY_PRESSED) {
        if (e.isControlDown()) {
            handleCtrlKey(key);
        } else if (e.isAltDown()) {
            handleAltKey(key);
        } else {
            handleNormalKey(key);
        }
    }
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:19,代码来源:GUILabelingTool.java

示例3: eventDispatched

/**
 * Popup should be closed under some circumstances. Namely when mouse is
 * pressed or released outside of popup or when key is pressed during the
 * time popup is visible.
 */
public void eventDispatched(AWTEvent event) {
    if (event.getSource() == this) {
        return;
    }
    if (event instanceof MouseEvent) {
        if (event.getID() == MouseEvent.MOUSE_RELEASED) {
            long time = System.currentTimeMillis();
            // check if button was just slowly clicked
            if (time - invocationTime > 500) {
                if (!onSwitcherTable((MouseEvent) event)) {
                    // Don't take any chances
                    hideCurrentPopup();
                }
            }
        } else if (event.getID() == MouseEvent.MOUSE_PRESSED) {
            if (!onSwitcherTable((MouseEvent) event)) {
                // Don't take any chances
                if (event.getSource() != invokingComponent) {
                    // If it's the invoker, don't do anything - it will
                    // generate another call to invoke(), which will do the
                    // hiding - if we do it here, it will get shown again
                    // when the button processes the event
                    hideCurrentPopup();
                }
            }
        }
    } else if (event instanceof KeyEvent) {
        if (event.getID() == KeyEvent.KEY_PRESSED) {
            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
            hideCurrentPopup();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ButtonPopupSwitcher.java

示例4: eventDispatched

@Override
public void eventDispatched(AWTEvent event) {
    if (event.getSource() == this) {
        return;
    }
    if (event instanceof KeyEvent) {
        if (event.getID() == KeyEvent.KEY_PRESSED) {
            if( !changeSelection( (KeyEvent)event ) ) {
                Toolkit.getDefaultToolkit().removeAWTEventListener(this);
                hideCurrentPopup();
            } else {
                ((KeyEvent)event).consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ButtonPopupSwitcher.java

示例5: postProcessKeyEvent

public boolean postProcessKeyEvent(final KeyEvent ev) {
    if (ev.getKeyCode() != KeyEvent.VK_ALT) {
        return false;
    }

    final JRootPane root = SwingUtilities.getRootPane(ev.getComponent());
    final Window winAncestor = (root == null ? null : SwingUtilities.getWindowAncestor(root));

    switch(ev.getID()) {
        case KeyEvent.KEY_PRESSED:
            setMnemonicHidden(false);
            break;
        case KeyEvent.KEY_RELEASED:
            setMnemonicHidden(true);
            break;
    }

    repaintMnemonicsInWindow(winAncestor);

    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:AquaMnemonicHandler.java

示例6: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent e) {
    switch (e.getID()) {
        case KeyEvent.KEY_PRESSED:
            //Do nothing
            break;
        case KeyEvent.KEY_RELEASED:
            if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
                guiInput.interruptThreads(true);
                guiInput.cancel(true); //Stop analysis thread
                IJ.showProgress(0); //Reset progress bar
                if(isGUI){
                    guiOKButton.setText("OK");
                    guiFrame.pack(); 
                }
                analysisStarted = false;
                IJ.showStatus("Analysis cancelled..."); //Update IJ status
                guiInput = new Hough_Circle(); //Create new instance of analysis worker, since last worker thread was cancelled
            }
            break;
        case KeyEvent.KEY_TYPED:
            //Do nothing
            break;
        default:
            break;
    }
    return false;
}
 
开发者ID:Llamero,项目名称:Local_Hough_Circle,代码行数:28,代码来源:Hough_GUI.java

示例7: handleF10JavaKeyEvent

void handleF10JavaKeyEvent(KeyEvent e) {
    if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_F10) {
        XWindowPeer winPeer = this.getToplevelXWindow();
        if (winPeer instanceof XFramePeer) {
            XMenuBarPeer mPeer = ((XFramePeer)winPeer).getMenubarPeer();
            if (mPeer != null) {
                mPeer.handleF10KeyPress(e);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:XComponentPeer.java

示例8: postProcessKeyEvent

@Override
public boolean postProcessKeyEvent(KeyEvent e) {
    Inputs input = keyCodeToInput(e.getKeyCode(), e.getKeyLocation());
    if (input == null) {
        return false;
    }
    if (e.getID() == KeyEvent.KEY_PRESSED) {
        status |= intBit(input.offset());
        return true;
    } else if (e.getID() == KeyEvent.KEY_RELEASED) {
        status &= ~intBit(input.offset());
        return true;
    }
    return false;
}
 
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:15,代码来源:DefaultSwingInputProvider.java

示例9: getKeyEventType

/**
 * Returns the type of {@code KeyEvent} which corresponds to
 * this {@code AWTKeyStroke}.
 *
 * @return {@code KeyEvent.KEY_PRESSED},
 *         {@code KeyEvent.KEY_TYPED},
 *         or {@code KeyEvent.KEY_RELEASED}
 * @see java.awt.event.KeyEvent
 */
public final int getKeyEventType() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return KeyEvent.KEY_TYPED;
    } else {
        return (onKeyRelease)
            ? KeyEvent.KEY_RELEASED
            : KeyEvent.KEY_PRESSED;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AWTKeyStroke.java

示例10: handleJavaKeyEvent

void handleJavaKeyEvent(KeyEvent e) {
    int id = e.getID();
    switch (id) {
      case KeyEvent.KEY_PRESSED:
          if (e.getKeyCode() == KeyEvent.VK_SPACE)
          {
              pressed=true;
              armed=true;
              repaint();
              action(e.getWhen(),e.getModifiers());
          }

          break;

      case KeyEvent.KEY_RELEASED:
          if (e.getKeyCode() == KeyEvent.VK_SPACE)
          {
              pressed = false;
              armed = false;
              repaint();
          }

          break;


    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:XButtonPeer.java

示例11: dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent e) {
    if (skippingEvents || e.isConsumed()) return false;
    
    if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE)
        if (SwingUtilities.getRootPane(this) != e.getSource()) { // Closing JPopupMenu using the ESC key
            e.consume();
            if (DEBUG) System.err.println(">>> Closed by ESC"); // NOI18N
            ProfilerPopup.this.hide();
            return true;
        }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProfilerPopup.java

示例12: postProcessKeyEvent

public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
        // mnemonic combination, it's consumed, but we need
        // set altKeyPressed to false, otherwise after selection
        // component by mnemonic combination a menu will be open
        altKeyPressed = false;
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        if (WindowsLookAndFeel.isMnemonicHidden() && ev.isAltDown()) {
            WindowsLookAndFeel.setMnemonicHidden(false);
            WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        }
        altKeyPressed = false;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:WindowsRootPaneUI.java

示例13: eventDispatched

public void eventDispatched(AWTEvent event) {
    if (event.getID() == MouseEvent.MOUSE_PRESSED || event.getID() == KeyEvent.KEY_PRESSED) {
        onClick(event);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:TooltipWindow.java

示例14: consumeTraversalKey

private void consumeTraversalKey(KeyEvent e) {
    e.consume();
    consumeNextKeyTyped = (e.getID() == KeyEvent.KEY_PRESSED) &&
                          !e.isActionKey();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:DefaultKeyboardFocusManager.java

示例15: dispatchEvent

/**
 * 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,代码行数:71,代码来源:CodePointInputMethod.java


注:本文中的java.awt.event.KeyEvent.KEY_PRESSED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。