本文整理匯總了Java中java.awt.event.KeyEvent.VK_ESCAPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.VK_ESCAPE屬性的具體用法?Java KeyEvent.VK_ESCAPE怎麽用?Java KeyEvent.VK_ESCAPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_ESCAPE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keyPressed
public void keyPressed (KeyEvent e) {
if ((e.getKeyCode () == KeyEvent.VK_ESCAPE && e.getModifiers () == 0) ||
(e.getKeyCode () == KeyEvent.VK_ENTER && e.getModifiers() == 0)
) {
if (highlights == null) return;
final List<Highlight> oldHighlights = highlights;
SwingUtilities.invokeLater (new Runnable () {
public void run () {
Iterator<Highlight> it = oldHighlights.iterator ();
while (it.hasNext ())
it.next ().remove ();
}
});
editor.removeKeyListener (this);
document.removeDocumentListener (this);
highlights = null;
elements = null;
editor = null;
document = null;
renameImplementation = null;
e.consume ();
}
}
示例2: processKeyEvent
/**
* Processes key events.
*
* @param e key event.
*/
@Override
protected void processKeyEvent(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_DELETE) {
if (!selection.isEmpty()) {
performAction(new DeleteComponentAction());
}
} else if ((keyCode == KeyEvent.VK_ESCAPE) && (moving || resizing)) {
// Cancel moving and resizing when Esc is pressed.
moving = false;
resizing = false;
repaint();
} else {
super.processKeyEvent(e);
}
}
示例3: respondToUserInput
@Override
public Screen respondToUserInput(final KeyEvent key, final MouseEvent mouse) {
if (key != null) {
final char c = key.getKeyChar();
final Item[] items = this.player.inventory().getItems();
if (this.letters.indexOf(c) > -1 && items.length > this.letters.indexOf(c)
&& items[this.letters.indexOf(c)] != null && this.isAcceptable(items[this.letters.indexOf(c)])) {
return this.use(items[this.letters.indexOf(c)]);
} else if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
return null;
} else {
return this;
}
} else {
return this;
}
}
示例4: keyPressed
@Override
public void keyPressed(KeyEvent e) {
shouldHide = false;
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
shouldHide = true;
break;
case KeyEvent.VK_ESCAPE:
shouldHide = true;
break;
case KeyEvent.VK_TAB:
setSelectedItem(getSearchString());
shouldHide = true;
default:
break;
}
}
示例5: 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;
}
}
示例6: keyPressed
public void keyPressed(KeyEvent evt){
switch(evt.getKeyCode()){
case KeyEvent.VK_LEFT:
bool_left2 = true;
bool_left = true;
bool_right = false;
break;
case KeyEvent.VK_RIGHT:
bool_right = true;
bool_right2 = true;
bool_left = false;
break;
case KeyEvent.VK_ESCAPE:
System.exit(0);
break;
}
}
示例7: 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;
}
示例8: keyReleased
/**
* Performs certain actions for certain keys:
* <ul>
* <li>Escape: close application</li>
* <li>V and B: cancel rotation</li>
* <li>N: clear rotation</li>
* </ul>
* @param e The key event
*/
@Override
public void keyReleased(KeyEvent e) {
if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
//Close application on escape
Utilities.closeApplication(frame);
} else if (KeyEvent.VK_V == e.getKeyCode() || KeyEvent.VK_B == e.getKeyCode()) {
//Cancel rotation
rotateTimer.stop();
} else if (KeyEvent.VK_N == e.getKeyCode()) {
mapController.setRotation(0);
mapController.getLocationController().setNavigationMode(NavigationMode.NORTH_UP);
}
}
示例9: keyPressed
public void keyPressed(KeyEvent e) {
// Krieg doch endlich den Code des Keys her
switch (e.getKeyCode()) {
// Wenn escape gedrueckt.. hICHWAREINUMLAUTr mal auf mit dem Thread, ok?
case KeyEvent.VK_ESCAPE:
System.exit(0);
}
}
示例10: keyPressed
@Override
synchronized public void keyPressed(int keycode) {
switch (keycode)
{
case KeyEvent.VK_UP:
up = true;
break;
case KeyEvent.VK_DOWN:
down = true;
break;
case KeyEvent.VK_LEFT:
left = true;
break;
case KeyEvent.VK_RIGHT:
right = true;
break;
case KeyEvent.VK_SPACE:
space = true;
break;
case KeyEvent.VK_M:
case KeyEvent.VK_ESCAPE:
StellarCrush.setState(-1);
System.exit(1);
break;
case KeyEvent.VK_P:
StellarCrush.screen();
break;
default:
if(StellarCrush.getState() == 0)//Start game
{
StellarCrush.setState(1);
}
break;
}
}
示例11: processKeyEvent
@Override
public void processKeyEvent(KeyEvent ke) {
//override the default handling so that
//the parent will never receive the escape key and
//close a modal dialog
if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
removeSearchField();
ke.consume(); // #44394
// bugfix #32909, reqest focus when search field is removed
NbList.this.requestFocus();
} else {
super.processKeyEvent(ke);
}
}
示例12: keyPressed
@Override
public void keyPressed(KeyEvent evt) {
showPopupCompletion = true;
int keyCode = evt.getKeyCode();
// #105801: completionPopup might not be ready when updateCompletions not called (empty text field)
if (completionPopup != null && !completionPopup.isVisible()) {
if (keyCode == KeyEvent.VK_ENTER) {
File file = getFileChooser().getFileSystemView().createFileObject(filenameTextField.getText());
if(file.exists() && file.isDirectory()) {
setSelected(new File[] {file});
fileChooser.approveSelection();
if (file.getParentFile() == null) {
// this will hopefully prevent popup to take inappropriate action
evt.consume();
}
}
}
if ((keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_DOWN) ||
(keyCode == KeyEvent.VK_RIGHT &&
(filenameTextField.getCaretPosition() >= (filenameTextField.getDocument().getLength() - 1)))) {
updateCompletions();
}
}
if(filenameTextField.isFocusOwner() &&
(completionPopup == null || !completionPopup.isVisible()) &&
keyCode == KeyEvent.VK_ESCAPE) {
fileChooser.cancelSelection();
}
}
示例13: keyPressed
public void keyPressed(KeyEvent k) {
// System.out.println("Key pressed: " + k.getKeyCode());
if (k.getKeyCode() == KeyEvent.VK_ENTER) {
finishCreate();
} else if (k.getKeyCode() == KeyEvent.VK_ESCAPE) {
dispose();
}
}
示例14: keyPressed
@Override
public void keyPressed(KeyEvent ke) {
if(ke.getSource() == frame.getjList1()) {
if(ke.getKeyCode() == KeyEvent.VK_UP ||
ke.getKeyCode() == KeyEvent.VK_DOWN) {
return;
} else if(ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
frame.setVisible(false);
} else if(ke.getKeyCode() == KeyEvent.VK_ENTER) {
String s = frame.getjList1().getSelectedValue();
if(s != null) choseCompletion(s);
frame.setVisible(false);
}
}
}
示例15: getTextForKeyChar
public static String getTextForKeyChar(char keyChar) {
int keycode;
switch (keyChar) {
case ' ':
keycode = KeyEvent.VK_SPACE;
break;
case '\b':
keycode = KeyEvent.VK_BACK_SPACE;
break;
case '\t':
keycode = KeyEvent.VK_TAB;
break;
case '\n':
keycode = KeyEvent.VK_ENTER;
break;
case '\u0018':
keycode = KeyEvent.VK_CANCEL;
break;
case '\u001b':
keycode = KeyEvent.VK_ESCAPE;
break;
case '\u007f':
keycode = KeyEvent.VK_DELETE;
break;
default:
return "" + keyChar;
}
return (String) keyCodes.get(Integer.valueOf(keycode));
}