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


Java KeyEvent.VK_SPACE属性代码示例

本文整理汇总了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;
	}
}
 
开发者ID:DreamBlocks,项目名称:DreamBlocks,代码行数:29,代码来源:AwtEventsHandler.java

示例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();
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:PanTiltGUI.java

示例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"));
		//}
	}
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:28,代码来源:FileChooserFixer.java

示例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);
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:24,代码来源:XMap.java

示例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;
    }
}
 
开发者ID:Silvanosky,项目名称:StellarCrush,代码行数:23,代码来源:MainKeyListener.java

示例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;
	}
}
 
开发者ID:DreamBlocks,项目名称:DreamBlocks,代码行数:27,代码来源:AwtEventsHandler.java

示例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);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:FlatterCheckBoxUI.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:WButtonPeer.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TypingInEditorTest.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: 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;
        }
    }
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:34,代码来源:MapEventHandler.java

示例12: keyReleased

public void keyReleased(KeyEvent e)
{
    int key = e.getKeyCode();

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

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ImportClassPanel.java

示例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;
	}
}
 
开发者ID:amymcgovern,项目名称:spacesettlers,代码行数:27,代码来源:HumanTeamClient.java

示例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);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:FlatterCheckBoxUI.java


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