本文整理汇总了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;
}
示例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);
}
}
}
示例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();
}
}
}
示例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();
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例13: eventDispatched
public void eventDispatched(AWTEvent event) {
if (event.getID() == MouseEvent.MOUSE_PRESSED || event.getID() == KeyEvent.KEY_PRESSED) {
onClick(event);
}
}
示例14: consumeTraversalKey
private void consumeTraversalKey(KeyEvent e) {
e.consume();
consumeNextKeyTyped = (e.getID() == KeyEvent.KEY_PRESSED) &&
!e.isActionKey();
}
示例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();
}