當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.VK_ESCAPE屬性代碼示例

本文整理匯總了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 ();
    }    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:InstantRenameAction.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:GlassPane.java

示例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;
}
   }
 
開發者ID:wrldwzrd89,項目名稱:dynamic-dungeon,代碼行數:17,代碼來源:InventoryBasedScreen.java

示例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;
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:17,代碼來源:AutoSuggest.java

示例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;
	}
}
 
開發者ID:DreamBlocks,項目名稱:DreamBlocks,代碼行數:29,代碼來源:AwtEventsHandler.java

示例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;
    }
}
 
開發者ID:Dexor157,項目名稱:collidethings,代碼行數:17,代碼來源:Game.java

示例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;
}
 
開發者ID:Llamero,項目名稱:Local_Hough_Circle,代碼行數:28,代碼來源:Hough_GUI.java

示例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);
    }
}
 
開發者ID:Esri,項目名稱:defense-solutions-proofs-of-concept,代碼行數:22,代碼來源:ApplicationKeyListener.java

示例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);
		}

	}
 
開發者ID:dviol,項目名稱:Project15,代碼行數:10,代碼來源:Game.java

示例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;
    }

}
 
開發者ID:Silvanosky,項目名稱:StellarCrush,代碼行數:37,代碼來源:MainKeyListener.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:ListView.java

示例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();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:DirectoryChooserUI.java

示例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();
        }
    }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:ZaurusConnectionDialog.java

示例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);
        } 
    }
}
 
開發者ID:Skypr,項目名稱:BEAST,代碼行數:15,代碼來源:AutocompletionController.java

示例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));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:29,代碼來源:KeyStrokeParser.java


注:本文中的java.awt.event.KeyEvent.VK_ESCAPE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。