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


Java KeyEvent.getKeyCode方法代码示例

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


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

示例1: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent ke) {
    int key = ke.getKeyCode();
    if (key == KeyEvent.VK_UP) {
      //  projectionModificationBegin();
        bDragging = true;
        dragAnim.animWithVelocity(0, DragAnim.MAX_VELOCITY*.7);
    } else if (key == KeyEvent.VK_DOWN) {
      //  projectionModificationBegin();
        bDragging = true;
        dragAnim.animWithVelocity(0, -DragAnim.MAX_VELOCITY*.7);            
    } else if (key == KeyEvent.VK_LEFT) {
      //  projectionModificationBegin();
        bDragging = true;
        dragAnim.animWithVelocity(DragAnim.MAX_VELOCITY*.7,0);            
    } else if (key == KeyEvent.VK_RIGHT) {
      //  projectionModificationBegin();
        dragAnim.animWithVelocity(-DragAnim.MAX_VELOCITY*.7,0);            
    }

}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:22,代码来源:PanelController.java

示例2: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void processKeyEvent(ExecutionUnit process, KeyEventType type, KeyEvent e) {
	// ignore if not active
	if (!isActive()) {
		return;
	}

	if (type == KeyEventType.KEY_PRESSED) {
		if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
			SHOW_ORDER_TOGGLEBUTTON.doClick();
		}
	}

	// no matter what, while flow visualizer is active we consume all events
	e.consume();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:FlowVisualizer.java

示例3: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
 * Notification from AWT that a key has been pressed. Note that
 * a key being pressed is equal to being pushed down but *NOT*
 * released. Thats where keyTyped() comes in.
 * 
 * @param e
 *            The details of the key that was pressed
 */
@Override
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	// Jump
	case KeyEvent.VK_W:
	// climb e jump
	case KeyEvent.VK_SPACE:
		game.player.startClimb();
		break;
	// move left
	case KeyEvent.VK_A:
		game.player.startLeft(e.isShiftDown());
		break;
	// move right
	case KeyEvent.VK_D:
		game.player.startRight(e.isShiftDown());
		break;
	}
}
 
开发者ID:DreamBlocks,项目名称:DreamBlocks,代码行数:28,代码来源:AwtEventsHandler.java

示例4: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent event) {
    synchronized (lock) {
        tempPress = true;
        lock.notifyAll();

        if (! startTest) {
            return;
        }
        for (int x = 0; x < inputMasks.length; x++) {
            if ((event.getModifiers() & inputMasks[x]) != 0) {
                System.out.println("Modifier set: " +
                                  event.getKeyModifiersText(inputMasks[x]));
                modifierStatus[x] = true;
            }
        }
        for (int x = 0; x < textKeys.length; x++) {
            if (event.getKeyCode() == textKeys[x]) {
                System.out.println("Text set: " +
                                             event.getKeyText(textKeys[x]));
                textStatus[x] = true;
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ModifierRobotKeyTest.java

示例5: postProcessKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
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 {
        altKeyPressed = false;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:WindowsRootPaneUI.java

示例6: keyTyped

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent ke) {       
    if(ke.getKeyCode() == KeyEvent.VK_LEFT ||
            ke.getKeyCode() == KeyEvent.VK_RIGHT ||
            ke.getKeyCode() == KeyEvent.VK_UP ||
            ke.getKeyCode() == KeyEvent.VK_DOWN) {
        return;
    }
    
    if(pane.getSelectedText() != null ||  
            ke.getKeyChar()== KeyEvent.VK_DELETE ||
            ke.getKeyChar()== KeyEvent.VK_BACK_SPACE ||
            (ke.isShiftDown() && ke.getKeyChar() == KeyEvent.VK_TAB)) {            
        try {
            prevText = pane.getStyledDocument().getText(0, pane.getStyledDocument().getLength());
        } catch (BadLocationException ex) {
            Logger.getLogger(SaveTextBeforeRemove.class.getName()).log(Level.SEVERE, null, ex);
        }
    }        
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:21,代码来源:SaveTextBeforeRemove.java

示例7: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    KeyStroke keyStroke = createKeyStroke(e);
    
    boolean add = e.getKeyCode() != e.VK_SHIFT &&
            e.getKeyCode() != e.VK_CONTROL &&
            e.getKeyCode() != e.VK_ALT &&
            e.getKeyCode() != e.VK_META &&
            e.getKeyCode() != e.VK_ALT_GRAPH;
    
    if (keyStroke.equals(backspaceKS) && !key.equals("")) {
        // delete last key
        int i = key.lastIndexOf(' ');
        if (i < 0)
            key = "";
        else
            key = key.substring(0, i);
        tfShortcut.setText(key);
    } else
        // add key
        addKeyStroke(keyStroke, add);
    
    e.consume();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ShortcutEnterPanel.java

示例8: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
	if (e.getKeyCode() == KeyEvent.VK_F5) {
		proj.getSimulator().requestReset();
		proj.getSimulator().setIsRunning(true);
	} else if ((e.getKeyCode() == KeyEvent.VK_0 || e.getKeyCode() == KeyEvent.VK_NUMPAD0)
			&& e.isControlDown()) {
		autoZoomCenter();
	} else {
		Tool tool = proj.getTool();
		if (tool != null)
			tool.keyPressed(Canvas.this, e);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:Canvas.java

示例9: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        TreePath[] paths = getSelectionPaths();

        if ((paths != null) && (paths.length > 0)) {
            Collection changedNodes = new ArrayList();

            for (int i = 0; i < paths.length; i++) {
                TreePath path = paths[i];

                if ((path != null) && (path.getPathCount() > 0) && path.getLastPathComponent() instanceof CheckTreeNode
                        && (((CheckTreeNode) path.getLastPathComponent()).isLeaf() || (i == (paths.length - 1)))) {
                    fireNodeToggled(path, true);
                }

                changedNodes.addAll(togglePathState(path));
                fireNodeToggled(path, false);
            }

            treeDidChange();
            fireCheckTreeChanged(changedNodes);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:JCheckTree.java

示例10: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent event) {
	enterFlag = false;
	if ((event.getKeyCode() == KeyEvent.VK_ENTER)
			&& (event.getModifiers() == 0)) {
		if (getSelectionStart() == getSelectionEnd()) {
			enterFlag = true;
			event.consume();
		}
	}
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:12,代码来源:XmlTextPane.java

示例11: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
	int code = e.getKeyCode();
	if (mouseDown && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_ALT)) {
		updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx());
		repaintArea(canvas);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:CurveTool.java

示例12: handleSpecialKey

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void handleSpecialKey(KeyEvent ke) {
    if(ke.getKeyCode() == KeyEvent.VK_END) {
        insertToCode.moveToEndOfCurrentLine();
    } else if(ke.getKeyCode() == KeyEvent.VK_HOME) {
        insertToCode.moveToStartOfCurrentLine();
    }  
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:8,代码来源:CodeInputHandler.java

示例13: letTextPaneHandleKey

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
private boolean letTextPaneHandleKey(KeyEvent ke) {
    return ke.getKeyCode() == KeyEvent.VK_LEFT ||
            ke.getKeyCode() == KeyEvent.VK_RIGHT ||
            ke.getKeyCode() == KeyEvent.VK_UP ||
            ke.getKeyCode() == KeyEvent.VK_DOWN ||
            ke.getKeyChar()== KeyEvent.VK_ESCAPE;                
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:8,代码来源:UserInputHandler.java

示例14: keyReleased

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyReleased(KeyEvent e)
{
    int key = e.getKeyCode();

    if(key == KeyEvent.VK_B && pressed)
    {
        pressed = false;
        QuestionHandler.backCard();
    }
}
 
开发者ID:jyao6429,项目名称:quizbowl-reader,代码行数:11,代码来源:Main.java

示例15: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {

        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:HintsPanelLogic.java


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