本文整理汇总了Java中java.awt.event.KeyEvent.VK_SPACE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_SPACE属性的具体用法?Java KeyEvent.VK_SPACE怎么用?Java KeyEvent.VK_SPACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_SPACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyReleased
/**
* Notification from AWT that a key has been released.
*
* @param e
* The details of the key that was released
*/
@Override
public void keyReleased(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_W:
case KeyEvent.VK_SPACE:
game.player.endClimb();
break;
case KeyEvent.VK_A:
game.player.stopLeft();
break;
case KeyEvent.VK_D:
game.player.stopRight();
break;
// pressed ESC to return to the game menu
case KeyEvent.VK_ESCAPE:
if (game.isInInventory()) {
game.closeInventory();
} else {
game.goToMainMenu();
}
break;
}
}
示例2: calibrationPanelKeyPressed
private void calibrationPanelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_calibrationPanelKeyPressed
switch (evt.getKeyCode()) {
case KeyEvent.VK_SPACE:
// send a message with pantilt and mouse filled in, tracker will fill in retina if there is a tracked locaton
support.firePropertyChange(Message.AddSample.name(), null, new PanTiltCalibrationPoint(new Point2D.Float(), (Point2D.Float)lastPanTilt.clone(), (Point)lastMousePressLocation.clone()));
repaint();
return;
case KeyEvent.VK_ENTER:
support.firePropertyChange(Message.ComputeCalibration.name(), null, null);
dispose();
break;
case KeyEvent.VK_BACK_SPACE:
support.firePropertyChange(Message.EraseLastSample.name(), null, null);
repaint();
break;
default:
Toolkit.getDefaultToolkit().beep();
}
}
示例3: keyPressed
/**
* Description of the Method
*
* @param evt Description of the Parameter
*/
public void keyPressed(KeyEvent evt) {
Object src = evt.getSource();
int code = evt.getKeyCode();
//changed by saruta
// if (code == KeyEvent.VK_ESCAPE)
// actionPerformed(new ActionEvent(cancelButton, 0, cancelButton.getActionCommand()));
if (src == fileList) {
if (code == KeyEvent.VK_SPACE || code == KeyEvent.VK_ENTER) {
File[] arr = getSelectedFiles();
if (arr.length == 1 && arr[0].isDirectory()) {
fileChooser.setCurrentDirectory(arr[0]);
}
evt.consume();
//filenameTextField.setText(arr[0].getPath());
}
//if (code == KeyEvent.VK_ENTER) {
// fileList.getSelectionModel().clearSelection();
// actionPerformed(new ActionEvent(okButton, 0, "enter"));
//}
}
}
示例4: keyReleased
public void keyReleased(KeyEvent e) {
if ( e.getKeyCode() == KeyEvent.VK_SPACE) {
setSpaceBarPress(false);
}
// If pan button in toolbar is selected replace with open hand cursor
if(((MapApp)app).tools.panB.isSelected() ){
Toolkit toolkit = Toolkit.getDefaultToolkit();
ClassLoader loader = org.geomapapp.util.Icons.class.getClassLoader();
String pathB = "org/geomapapp/resources/icons/open_hand.png";
java.net.URL url = loader.getResource(pathB);
setSpaceBarPress(false);
try {
BufferedImage im = ImageIO.read(url);
Cursor openHandCursor = toolkit.createCustomCursor( im, new Point(0,0), "close_hand");
setCursor(openHandCursor);
} catch (IOException e1) {
e1.printStackTrace();
}
}
else if(!getSpaceBarPress()){
setCursor(Cursor.getDefaultCursor());
setSpaceBarPress(false);
}
}
示例5: keyReleased
@Override
synchronized public void keyReleased(int keycode) {
switch (keycode)
{
case KeyEvent.VK_UP:
up = false;
break;
case KeyEvent.VK_DOWN:
down = false;
break;
case KeyEvent.VK_LEFT:
left = false;
break;
case KeyEvent.VK_RIGHT:
right = false;
break;
case KeyEvent.VK_SPACE:
space = false;
break;
default:
break;
}
}
示例6: keyPressed
/**
* 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;
}
}
示例7: keyPressed
@Override
public synchronized void keyPressed(KeyEvent e)
{
int code = e.getKeyCode();
if( code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE )
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextPressed);
c.setBackground(mBackgroundPressed);
}
}
示例8: handleJavaKeyEvent
@Override
public boolean handleJavaKeyEvent(KeyEvent e) {
switch (e.getID()) {
case KeyEvent.KEY_RELEASED:
if (e.getKeyCode() == KeyEvent.VK_SPACE){
handleAction(e.getWhen(), e.getModifiers());
}
break;
}
return false;
}
示例9: testJavaEditor10Enter
public void testJavaEditor10Enter() {
expectedTime = 400;
keyCode = KeyEvent.VK_ENTER;
repeatTimes = 10;
fileName = "Main.java";
caretPositionX = 9;
caretPositionY = 1;
fileToBeOpened = new Node(new SourcePackagesNode("PerformanceTestData"), "org.netbeans.test.performance|" + fileName);
doMeasurement();
keyCode = KeyEvent.VK_SPACE;
repeatTimes = 1;
}
示例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: updateKeyStates
/**
* Helper method that keeps track of the pressed special keys (space, meta
* and alt key).
*
* @param keyEvent The key event to analyze.
*/
private void updateKeyStates(KeyEvent keyEvent) {
// update spaceKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_SPACE) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
spaceKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
spaceKeyDown = true;
}
}
// update metaKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_META) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
metaKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
metaKeyDown = true;
}
}
// update altKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_ALT) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
altKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
altKeyDown = true;
}
}
}
示例12: keyReleased
public void keyReleased(KeyEvent e)
{
int key = e.getKeyCode();
if(key == KeyEvent.VK_SPACE && pressed)
{
pressed = false;
QuestionHandler.buzz();
}
}
示例13: listKeyReleased
private void listKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listKeyReleased
KeyStroke ks = KeyStroke.getKeyStrokeForEvent(evt);
if ( ks.getKeyCode() == KeyEvent.VK_ENTER ||
ks.getKeyCode() == KeyEvent.VK_SPACE ) {
importClass(
getSelected(),
(evt.getModifiers() & (org.openide.util.Utilities.isMac() ? InputEvent.META_MASK : InputEvent.ALT_MASK)) > 0,
(evt.getModifiers() & InputEvent.SHIFT_MASK) > 0);
}
}
示例14: keyPressed
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
//System.out.println("human pressed " + key);
if (key == KeyEvent.VK_UP || key == KeyEvent.VK_KP_UP) {
// UP means accelerate forward
lastKeyPressed = HumanKeyPressed.UP;
//System.out.println("human pressed UP ");
} else if (key == KeyEvent.VK_DOWN || key == KeyEvent.VK_KP_DOWN) {
// DOWN means decelerate
lastKeyPressed = HumanKeyPressed.DOWN;
} else if (key == KeyEvent.VK_RIGHT || key == KeyEvent.VK_KP_RIGHT) {
// turn RIGHT
lastKeyPressed = HumanKeyPressed.RIGHT;
} else if (key == KeyEvent.VK_LEFT || key == KeyEvent.VK_KP_LEFT) {
// turn LEFT
lastKeyPressed = HumanKeyPressed.LEFT;
} else if (key == KeyEvent.VK_SPACE) {
// fire
lastKeyPressed = HumanKeyPressed.FIRE;
}
if (lastKeyPressed != null) {
lastMouseClick = null;
}
}
示例15: keyReleased
@Override
public synchronized void keyReleased(KeyEvent e)
{
int code = e.getKeyCode();
if( code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE )
{
JComponent c = (JComponent) e.getComponent();
c.setForeground(mTextNormal);
c.setBackground(mBackgroundNormal);
}
}