List of usage examples for java.awt.event KeyEvent VK_SPACE
int VK_SPACE
To view the source code for java.awt.event KeyEvent VK_SPACE.
Click Source Link
From source file:com.chaosting.product.hotkey.Main.java
/** * case ascii in (33,34,35,36,37,38,40...)shiftkeycode,keyperss(shift)keyrelease(shift) * /* ww w . ja v a2 s . co m*/ * String temp = "!@#$%^&()_+{}|:\"<>?"; * String temp = "*-=[]\\;',./"; * * @param ascii * @return */ private int convertAsciiInt2KeycodeInt(int ascii) { if (ascii >= 65 && ascii <= 90) { return ascii; } if (ascii >= 48 && ascii <= 57) { return ascii + 48; } if (ascii >= 97 && ascii <= 122) { return ascii - 32; } switch (ascii) { case 13: return KeyEvent.VK_ENTER; case 32: return KeyEvent.VK_SPACE; //case 33: // return KeyEvent.VK_EXCLAMATION_MARK; //case 34: // return KeyEvent.VK_QUOTEDBL; //case 35: // return KeyEvent.VK_NUMBER_SIGN; //case 36: // return KeyEvent.VK_DOLLAR; // 37 % // 38 & case 39: return KeyEvent.VK_QUOTE; //case 40: // return KeyEvent.VK_LEFT_PARENTHESIS; //case 41: // return KeyEvent.VK_RIGHT_PARENTHESIS; case 42: return KeyEvent.VK_MULTIPLY; //case 43: // return KeyEvent.VK_PLUS; case 44: return KeyEvent.VK_COMMA; case 45: return KeyEvent.VK_MINUS; case 46: return KeyEvent.VK_PERIOD; case 47: return KeyEvent.VK_SLASH; //case 58: // return KeyEvent.VK_COLON; case 59: return KeyEvent.VK_SEMICOLON; //case 60: // return KeyEvent.VK_LESS; case 61: return KeyEvent.VK_EQUALS; //case 62: // return KeyEvent.VK_GREATER; // 63 ? //case 64: // return KeyEvent.VK_AT; case 91: return KeyEvent.VK_OPEN_BRACKET; case 92: return KeyEvent.VK_BACK_SLASH; case 93: return KeyEvent.VK_CLOSE_BRACKET; //case 94: // return KeyEvent.VK_CIRCUMFLEX; //case 95: // return KeyEvent.VK_UNDERSCORE; // 96 ` //case 123: // return KeyEvent.VK_BRACELEFT; // 124 | //case 125: // return KeyEvent.VK_BRACERIGHT; // 126 ~ default: return -1; } }
From source file:org.kalypso.ogc.gml.map.widgets.advanced.edit.AdvancedPolygonEditWidget.java
/** * Escape Key pressed? -> reset / deactivate widget * //from w w w . ja va2 s . c o m * @see org.kalypso.ogc.gml.widgets.AbstractWidget#keyReleased(java.awt.event.KeyEvent) */ @Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); if (KeyEvent.VK_SPACE == keyCode) { switchMode(); } super.keyReleased(e); }
From source file:com.frostwire.gui.player.MediaPlayer.java
protected MediaPlayer() { lastRandomFiles = new LinkedList<MediaSource>(); playExecutor = ExecutorsHelper.newProcessingQueue("AudioPlayer-PlayExecutor"); String playerPath;/* w w w . ja va2 s .co m*/ playerPath = getPlayerPath(); MPlayer.initialise(new File(playerPath)); mplayer = new MPlayer(); mplayer.addPositionListener(new PositionListener() { public void positionChanged(float currentTimeInSecs) { notifyProgress(currentTimeInSecs); } }); mplayer.addStateListener(new StateListener() { public void stateChanged(MediaPlaybackState newState) { if (newState == MediaPlaybackState.Closed) { // This is the case // mplayer is // done with the // current file playNextMedia(); } } }); mplayer.addIcyInfoListener(new IcyInfoListener() { public void newIcyInfoData(String data) { notifyIcyInfo(data); } }); repeatMode = RepeatMode.values()[PlayerSettings.LOOP_PLAYLIST.getValue()]; shuffle = PlayerSettings.SHUFFLE_PLAYLIST.getValue(); playNextMedia = true; volume = PlayerSettings.PLAYER_VOLUME.getValue(); notifyVolumeChanged(); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_SPACE) { Object s = e.getComponent(); if (!(s instanceof JTextField) && !(s instanceof JTable && ((JTable) s).isEditing() && !(s instanceof JCheckBox))) { togglePause(); return true; } } return false; } }); // prepare to receive UI events MPlayerUIEventHandler.instance().addListener(this); }
From source file:org.kalypso.ogc.gml.map.widgets.GetFeatureInfoWidget.java
/** * @see org.kalypso.ogc.gml.widgets.AbstractWidget#keyPressed(java.awt.event.KeyEvent) *///from w w w . j ava 2s. c o m @Override public void keyPressed(final KeyEvent event) { /* Get the key code. */ final int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.VK_SPACE: { openDialog(); break; } } }
From source file:ToggleSample.java
public void processKeyEvent(KeyEvent keyEvent, MenuElement path[], MenuSelectionManager manager) { // If user presses space while menu item armed, select it if (getModel().isArmed()) { int keyChar = keyEvent.getKeyChar(); if (keyChar == KeyEvent.VK_SPACE) { manager.clearSelectedPath(); doClick(0); // inherited from AbstractButton }/*w ww . ja va 2 s . c o m*/ } }
From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java
private JEditorPane createCodePane(URL sourceCodeURL) { codePane = new JEditorPane() { @Override/*from w w w. j a v a 2 s .co m*/ protected void processComponentKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) { System.out.println("Code completion"); int caretPosition = codePane.getCaretPosition(); String code = codePane.getText(); switch (code.charAt(caretPosition - 1)) { case '.': int pseudoCaret = caretPosition - 1; StringBuilder word = new StringBuilder(); for (char c = code.charAt(--pseudoCaret); !isEndOfWord(c); c = code.charAt(--pseudoCaret)) { word.append(c); } word = word.reverse(); System.out.println("WORD: " + word); // Class<?> type = // ReflectionUtil.loadClass(word.toString()); // // System.out.println("TYPE: " + type); JPopupMenu menu = new JPopupMenu("sdaf"); Point p = codePane.getCaret().getMagicCaretPosition(); System.out.println("CARET POS: " + p); // Point p = codePane.get // menu.setPreferredSize(new Dimension(200, 200)); menu.setLocation(30, 30); menu.add("test"); codePane.add(menu); // System.out.println(p); // codePane.get menu.show(codePane, p.x, p.y); break; } } super.processComponentKeyEvent(e); } /** * @param c * @return */ private boolean isEndOfWord(char c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t'; } }; EditorKit editorKit = new StyledEditorKit() { /** * */ private static final long serialVersionUID = 7024886168909204806L; public Document createDefaultDocument() { return new SyntaxDocument(); } }; codePane.setEditorKitForContentType("text/java", editorKit); codePane.setContentType("text/java"); try { FileInputStream fis = new FileInputStream(sourceCodeURL.getPath()); codePane.read(fis, null); originSourceCode = codePane.getText(); computeHeightOfCodePane(); codePane.setAutoscrolls(true); } catch (Exception e) { codePane.setText("File not found!"); } codePane.requestFocus(); codePane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); codePane.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_SPACE: computeHeightOfCodePane(); break; } markDirty(); } }); // final JPopupMenu menu = new JPopupMenu(); // // JMenuItem i = new JMenuItem("Option 1"); // JMenuItem i2 = new JMenuItem("Option 2"); // menu.add(i); // menu.add(i2); // edit.add(menu); // getComponent().addKeyListener(new KeyAdapter() { // // public void keyTyped(KeyEvent e) { // if(e.getModifiers() == 2 && e.getKeyChar() == ' ') { // Point popupLoc = edit.getCaret().getMagicCaretPosition(); // System.out.println(popupLoc); // menu.setLocation(new // Point((int)popupLoc.getX(),(int)popupLoc.getY())); // menu.setVisible(true); // } // // } // }); return codePane; }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java
@Override public void keyPressed(final KeyEvent e) { final int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_ESCAPE: reinit();// ww w . ja v a2 s . co m break; case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: if (m_lineBuilder != null && !m_edit) m_lineBuilder.removeLastPoint(); break; // switch mode case KeyEvent.VK_SPACE: if (m_edit == true) m_edit = false; else { m_edit = true; if (m_bankline != null & m_lineEditor == null) m_lineEditor = new LineGeometryEditor(new GM_Curve[] { m_bankline }, m_bankline, getMapPanel()); } break; } repaintMap(); }
From source file:ru.goodfil.catalog.ui.forms.OePanel.java
private void lstBrandsKeyPressed(KeyEvent e) { if (e != null) { if (e.getKeyCode() == KeyEvent.VK_INSERT) { btnCreateBrandActionPerformed(null); }/*from w w w. j a v a2s . c om*/ if (e.getKeyCode() == KeyEvent.VK_DELETE) { btnRemoveBrandActionPerformed(null); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { btnEditBrandActionPerformed(null); } } }
From source file:com.mirth.connect.client.ui.components.rsta.RSTAPreferences.java
private void setDefaultKeyStrokeMap() { keyStrokeMap = new HashMap<String, KeyStroke>(); boolean isOSX = RTextArea.isOSX(); int defaultModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); int ctrl = InputEvent.CTRL_MASK; int alt = InputEvent.ALT_MASK; int shift = InputEvent.SHIFT_MASK; int defaultShift = defaultModifier | shift; int moveByWordMod = isOSX ? alt : defaultModifier; int moveByWordModShift = moveByWordMod | shift; putKeyStroke(ActionInfo.UNDO, KeyEvent.VK_Z, defaultModifier); if (isOSX) {//from w w w . ja v a2 s.co m putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Z, defaultShift); } else { putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Y, defaultModifier); } putKeyStroke(ActionInfo.CUT, KeyEvent.VK_X, defaultModifier); putKeyStroke(ActionInfo.COPY, KeyEvent.VK_C, defaultModifier); putKeyStroke(ActionInfo.PASTE, KeyEvent.VK_V, defaultModifier); putKeyStroke(ActionInfo.DELETE, KeyEvent.VK_DELETE, 0); putKeyStroke(ActionInfo.DELETE_REST_OF_LINE, KeyEvent.VK_DELETE, defaultModifier); putKeyStroke(ActionInfo.DELETE_LINE, KeyEvent.VK_D, defaultModifier); putKeyStroke(ActionInfo.JOIN_LINE, KeyEvent.VK_J, defaultModifier); putKeyStroke(ActionInfo.SELECT_ALL, KeyEvent.VK_A, defaultModifier); putKeyStroke(ActionInfo.FIND_REPLACE, KeyEvent.VK_F, defaultModifier); putKeyStroke(ActionInfo.FIND_NEXT, KeyEvent.VK_G, defaultModifier); putKeyStroke(ActionInfo.CLEAR_MARKED_OCCURRENCES, KeyEvent.VK_ESCAPE, 0); putKeyStroke(ActionInfo.FOLD_COLLAPSE, KeyEvent.VK_SUBTRACT, defaultModifier); putKeyStroke(ActionInfo.FOLD_EXPAND, KeyEvent.VK_ADD, defaultModifier); putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL, KeyEvent.VK_DIVIDE, defaultModifier); putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS, KeyEvent.VK_DIVIDE, defaultShift); putKeyStroke(ActionInfo.FOLD_EXPAND_ALL, KeyEvent.VK_MULTIPLY, defaultModifier); putKeyStroke(ActionInfo.GO_TO_MATCHING_BRACKET, KeyEvent.VK_OPEN_BRACKET, defaultModifier); putKeyStroke(ActionInfo.TOGGLE_COMMENT, KeyEvent.VK_SLASH, defaultModifier); putKeyStroke(ActionInfo.AUTO_COMPLETE, KeyEvent.VK_SPACE, ctrl); if (isOSX) { putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, 0); putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, 0); putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, shift); putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, shift); putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_LEFT, defaultModifier); putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_RIGHT, defaultModifier); putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_LEFT, defaultShift); putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_RIGHT, defaultShift); } else { putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, defaultModifier); putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, defaultModifier); putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, defaultShift); putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, defaultShift); putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_HOME, 0); putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_END, 0); putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_HOME, shift); putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_END, shift); } putKeyStroke(ActionInfo.MOVE_LEFT, KeyEvent.VK_LEFT, 0); putKeyStroke(ActionInfo.MOVE_LEFT_SELECT, KeyEvent.VK_LEFT, shift); putKeyStroke(ActionInfo.MOVE_LEFT_WORD, KeyEvent.VK_LEFT, moveByWordMod); putKeyStroke(ActionInfo.MOVE_LEFT_WORD_SELECT, KeyEvent.VK_LEFT, moveByWordModShift); putKeyStroke(ActionInfo.MOVE_RIGHT, KeyEvent.VK_RIGHT, 0); putKeyStroke(ActionInfo.MOVE_RIGHT_SELECT, KeyEvent.VK_RIGHT, shift); putKeyStroke(ActionInfo.MOVE_RIGHT_WORD, KeyEvent.VK_RIGHT, moveByWordMod); putKeyStroke(ActionInfo.MOVE_RIGHT_WORD_SELECT, KeyEvent.VK_RIGHT, moveByWordModShift); putKeyStroke(ActionInfo.MOVE_UP, KeyEvent.VK_UP, 0); putKeyStroke(ActionInfo.MOVE_UP_SELECT, KeyEvent.VK_UP, shift); putKeyStroke(ActionInfo.MOVE_UP_SCROLL, KeyEvent.VK_UP, defaultModifier); putKeyStroke(ActionInfo.MOVE_UP_LINE, KeyEvent.VK_UP, alt); putKeyStroke(ActionInfo.MOVE_DOWN, KeyEvent.VK_DOWN, 0); putKeyStroke(ActionInfo.MOVE_DOWN_SELECT, KeyEvent.VK_DOWN, shift); putKeyStroke(ActionInfo.MOVE_DOWN_SCROLL, KeyEvent.VK_DOWN, defaultModifier); putKeyStroke(ActionInfo.MOVE_DOWN_LINE, KeyEvent.VK_DOWN, alt); putKeyStroke(ActionInfo.PAGE_UP, KeyEvent.VK_PAGE_UP, 0); putKeyStroke(ActionInfo.PAGE_UP_SELECT, KeyEvent.VK_PAGE_UP, shift); putKeyStroke(ActionInfo.PAGE_LEFT_SELECT, KeyEvent.VK_PAGE_UP, defaultShift); putKeyStroke(ActionInfo.PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, 0); putKeyStroke(ActionInfo.PAGE_DOWN_SELECT, KeyEvent.VK_PAGE_DOWN, shift); putKeyStroke(ActionInfo.PAGE_RIGHT_SELECT, KeyEvent.VK_PAGE_DOWN, defaultShift); putKeyStroke(ActionInfo.INSERT_LF_BREAK, KeyEvent.VK_ENTER, 0); putKeyStroke(ActionInfo.INSERT_CR_BREAK, KeyEvent.VK_ENTER, shift); putKeyStroke(ActionInfo.MACRO_BEGIN, KeyEvent.VK_B, defaultShift); putKeyStroke(ActionInfo.MACRO_END, KeyEvent.VK_N, defaultShift); putKeyStroke(ActionInfo.MACRO_PLAYBACK, KeyEvent.VK_M, defaultShift); }
From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java
@Override public void registerSpaceKey(final Action action) { registerKey(KeyEvent.VK_SPACE, 0, action); }