Java Code Examples for java.awt.event.KeyEvent#VK_DOWN
The following examples show how to use
java.awt.event.KeyEvent#VK_DOWN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java From javagame with MIT License | 8 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.press(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.press(); } if (keyCode == KeyEvent.VK_UP) { upKey.press(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.press(); } }
Example 2
Source File: CsvTableEditorKeyListenerTest.java From intellij-csv-validator with Apache License 2.0 | 6 votes |
public void testAddRowAfterAction() { KeyEvent keyEvent = new KeyEvent(fileEditor.getTable(), KeyEvent.KEY_RELEASED, JComponent.WHEN_FOCUSED, KeyEvent.CTRL_DOWN_MASK, KeyEvent.VK_DOWN, KeyEvent.CHAR_UNDEFINED); fileEditor.tableEditorKeyListener.keyReleased(keyEvent); Object[][] newState = fileEditor.getDataHandler().getCurrentState(); assertEquals(initialState.length + 1, newState.length); assertEquals("Header1", newState[0][0]); assertEquals("header 2", newState[0][1]); assertEquals("", newState[4][0]); assertEquals("", newState[4][1]); fileEditor.tableEditorActions.undo.actionPerformed(null); fileEditor.getTable().setRowSelectionInterval(1, 1); fileEditor.getTable().setColumnSelectionInterval(1, 1); fileEditor.tableEditorKeyListener.keyReleased(keyEvent); newState = fileEditor.getDataHandler().getCurrentState(); assertEquals(initialState.length + 1, newState.length); assertEquals("", newState[2][0]); assertEquals("", newState[2][1]); assertEquals(1, fileEditor.getTable().getSelectedRow()); assertEquals(1, fileEditor.getTable().getSelectedColumn()); }
Example 3
Source File: PdfPanel.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void keyPressed(KeyEvent event) { if (!event.isConsumed() && (event.getModifiersEx() & getToolkit().getMenuShortcutKeyMaskEx()) == 0) { switch (event.getKeyCode()) { case KeyEvent.VK_UP: previousPage(); break; case KeyEvent.VK_DOWN: nextPage(); break; default: return; } event.consume(); } }
Example 4
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.press(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.press(); } if (keyCode == KeyEvent.VK_UP) { upKey.press(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.press(); } if (keyCode == KeyEvent.VK_SPACE) { spaceKey.press(); } }
Example 5
Source File: MainPanel.java From JavaBase with MIT License | 6 votes |
@Override public void keyPressed(KeyEvent e) { // if (Move.count == 0) { // randomKey(move); // } if (e.getKeyCode() == KeyEvent.VK_UP) { ImageBlockMgr.move.moveW(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_DOWN) { ImageBlockMgr.move.moveS(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_LEFT) { ImageBlockMgr.move.moveA(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { ImageBlockMgr.move.moveD(); repaint(); } //继承了JPanel才可以调用repaint函数 repaint(); }
Example 6
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.press(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.press(); } if (keyCode == KeyEvent.VK_UP) { upKey.press(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.press(); } if (keyCode == KeyEvent.VK_SPACE) { spaceKey.press(); } }
Example 7
Source File: GameKeyHandler.java From stendhal with GNU General Public License v2.0 | 6 votes |
@Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); /* Ignore if the key is not found in the pressedStateKeys list. */ if (client.keyIsPressed(keyCode)) { /* Remove keyCode from pressedStateKeys list. */ client.onKeyReleased(keyCode); switch (keyCode) { case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_KP_UP: case KeyEvent.VK_KP_DOWN: /* * Ctrl means face, otherwise move */ processDirectionRelease(keyCodeToDirection(e.getKeyCode()), e.isControlDown()); } } }
Example 8
Source File: MainPanel.java From javagame with MIT License | 6 votes |
public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { // �u���b�N�����ֈړ� block.move(Block.LEFT); } else if (key == KeyEvent.VK_RIGHT) { // �u���b�N���E�ֈړ� block.move(Block.RIGHT); } else if (key == KeyEvent.VK_DOWN) { // �u���b�N�����ֈړ� block.move(Block.DOWN); } else if (key == KeyEvent.VK_SPACE || key == KeyEvent.VK_UP) { // �u���b�N����] block.turn(); } else if (key == KeyEvent.VK_N) { // �o�[�u���b�N��\�� block.createBarBlock(); } repaint(); }
Example 9
Source File: DQ.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.release(); cmdLeftKey.release(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.release(); cmdRightKey.release(); } if (keyCode == KeyEvent.VK_UP) { upKey.release(); cmdUpKey.release(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.release(); cmdDownKey.release(); } if (keyCode == KeyEvent.VK_SPACE) { spaceKey.release(); } }
Example 10
Source File: MainPanel.java From javagame with MIT License | 6 votes |
public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { // �u���b�N�����ֈړ� block.move(Block.LEFT); } else if (key == KeyEvent.VK_RIGHT) { // �u���b�N���E�ֈړ� block.move(Block.RIGHT); } else if (key == KeyEvent.VK_DOWN) { // �u���b�N�����ֈړ� block.move(Block.DOWN); scorePanel.upScore(BLOCK_DOWN); } else if (key == KeyEvent.VK_SPACE || key == KeyEvent.VK_UP) { // �u���b�N����] block.turn(); } repaint(); }
Example 11
Source File: ListKeyboardDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void selectItem(ComponentOperator oper, int index) { ListOperator loper = (ListOperator) oper; if (loper.isMultipleMode()) { super.selectItem(loper, index); } DriverManager.getFocusDriver(oper).giveFocus(oper); KeyDriver kDriver = DriverManager.getKeyDriver(oper); int current = loper.getSelectedIndex(); int diff = 0; int key = 0; if (index > current) { diff = index - current; key = KeyEvent.VK_DOWN; } else { diff = current - index; key = KeyEvent.VK_UP; } Timeout pushTime = oper.getTimeouts().create("ComponentOperator.PushKeyTimeout"); for (int i = 0; i < diff; i++) { kDriver.pushKey(oper, key, 0, pushTime); } kDriver.pushKey(oper, KeyEvent.VK_ENTER, 0, pushTime); }
Example 12
Source File: Block.java From JavaGame with MIT License | 6 votes |
/** * ���̰����¼� * * @param e */ public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: case KeyEvent.VK_W: rotate = true; down = left = right = false; break; case KeyEvent.VK_DOWN: case KeyEvent.VK_S: down = true; rotate = left = right = false; break; case KeyEvent.VK_LEFT: case KeyEvent.VK_A: left = true; rotate = right = down = false; break; case KeyEvent.VK_RIGHT: case KeyEvent.VK_D: right = true; rotate = left = down = false; break; } }
Example 13
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.release(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.release(); } if (keyCode == KeyEvent.VK_UP) { upKey.release(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.release(); } if (keyCode == KeyEvent.VK_SPACE) { spaceKey.release(); } }
Example 14
Source File: FilterDropDown.java From azure-devops-intellij with MIT License | 6 votes |
public FilterDropDown() { this.group = new DefaultActionGroup(); this.clickListener = new ClickListener() { @Override public boolean onClick(MouseEvent event, int clickCount) { showDropDownMenu(); return true; } }; this.keyAdapter = new KeyAdapter() { @Override public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER || keyEvent.getKeyCode() == KeyEvent.VK_DOWN) { showDropDownMenu(); } } }; }
Example 15
Source File: Editor.java From brModelo with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { if (diagramaAtual != null) { switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_ESCAPE: case KeyEvent.VK_ENTER: diagramaAtual.ProcesseTeclas(e); break; case KeyEvent.VK_DELETE: if (diagramaAtual != null) { diagramaAtual.deleteSelecao(); e.consume(); } break; case KeyEvent.VK_TAB: if (e.isControlDown()) { if (e.isShiftDown()) { if (diagramaAtual.SelecioneAnterior()) { e.consume(); } } else if (diagramaAtual.SelecioneProximo()) { e.consume(); } } else { transferFocus(); } break; } } }
Example 16
Source File: ListView.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ESCAPE) { removeSearchField(); NbList.this.requestFocus(); } else if (keyCode == KeyEvent.VK_UP) { currentSelectionIndex--; displaySearchResult(); // Stop processing the event here. Otherwise it's dispatched // to the tree too (which scrolls) e.consume(); } else if (keyCode == KeyEvent.VK_DOWN) { currentSelectionIndex++; displaySearchResult(); // Stop processing the event here. Otherwise it's dispatched // to the tree too (which scrolls) e.consume(); } else if (keyCode == KeyEvent.VK_TAB) { if (maxPrefix != null) { searchTextField.setText(maxPrefix); } e.consume(); } else if (keyCode == KeyEvent.VK_ENTER) { removeSearchField(); NbList.this.requestFocus(); NbList.this.dispatchEvent(e); } }
Example 17
Source File: ShortcutOptionsPanel.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Action triggered when keyboard is used. * * @param e Event. * @return True if processing should end. * @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent) */ @Override public boolean dispatchKeyEvent(KeyEvent e) { int key = e.getKeyCode(); if ((key == KeyEvent.VK_ALT) || (key == KeyEvent.VK_ALT_GRAPH) || (key == KeyEvent.VK_BACK_SPACE) || (key == KeyEvent.VK_BEGIN) || (key == KeyEvent.VK_CANCEL) || (key == KeyEvent.VK_CAPS_LOCK) || (key == KeyEvent.VK_CONTROL) || (key == KeyEvent.VK_DELETE) || (key == KeyEvent.VK_DOWN) || (key == KeyEvent.VK_END) || (key == KeyEvent.VK_ENTER) || (key == KeyEvent.VK_LEFT) || (key == KeyEvent.VK_PAGE_DOWN) || (key == KeyEvent.VK_PAGE_UP) || (key == KeyEvent.VK_RIGHT) || (key == KeyEvent.VK_SHIFT) || (key == KeyEvent.VK_TAB) || (key == KeyEvent.VK_UP) || (key == KeyEvent.VK_SHIFT)) { return false; } if (key != KeyEvent.VK_ESCAPE) { setKeyCode(key); } showNotice(false); KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this); return false; }
Example 18
Source File: MainFrameKeyListener.java From tankbattle with MIT License | 5 votes |
@Override public void keyReleased(KeyEvent e) { RealTimeGameData data = gameContext.getRealTimeGameData(); if (e.getKeyCode() == KeyEvent.VK_UP) { data.setUp(false); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { data.setDown(false); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { data.setLeft(false); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { data.setRight(false); } }
Example 19
Source File: EditorPropertyDisplayer.java From netbeans with Apache License 2.0 | 4 votes |
protected final void replaceInner() { inReplaceInner = true; try { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner(); boolean hadFocus = isEnabled() && ((focusOwner == this) || isAncestorOf(focusOwner) || ((getInplaceEditor() != null) && getInplaceEditor().isKnownComponent(focusOwner))); //Figure out if a combo popup was open, so we can re-open it. //If we're processing a mouse event, close it because that's //the normal behavior of a popup. We want arrow keyboard events //to not trigger closing of the popup if they caused a change //to a value that is marked as invalid boolean wasComboPopup = hadFocus && focusOwner instanceof JComboBox && ((JComboBox) focusOwner).isPopupVisible() && (EventQueue.getCurrentEvent() instanceof KeyEvent && ((((KeyEvent) EventQueue.getCurrentEvent()).getKeyCode() == KeyEvent.VK_UP) || (((KeyEvent) EventQueue.getCurrentEvent()).getKeyCode() == KeyEvent.VK_DOWN))); // System.err.println("REPLACE INNER - " + prop.getDisplayName() + " focus:" + hadFocus); if (hadFocus) { //We don't want focus to jump to another component and back KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } setInplaceEditor(createInplaceEditor()); if (hadFocus) { requestFocus(); //At this point the focus owner is still null, the event is queued - if (wasComboPopup) { //We have to let the request focus on the event queue get //processed before this can be done, or the component will //not yet be laid out and the popup will be 1 pixel wide SwingUtilities.invokeLater( new Runnable() { public void run() { InplaceEditor ied = getInplaceEditor(); ied = PropUtils.findInnermostInplaceEditor(ied); JComponent c = ied.getComponent(); if (c instanceof JComboBox && c.isShowing()) { ((JComboBox) c).showPopup(); } } } ); } } revalidate(); repaint(); } catch (Exception e) { e.printStackTrace(); } finally { inReplaceInner = false; } }
Example 20
Source File: Diagrama.java From brModelo with GNU General Public License v3.0 | 4 votes |
/** * Recebe as teclas do Editor. * * @param e */ public void ProcesseTeclas(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { setComando(null); return; } if (e.getKeyCode() == KeyEvent.VK_ENTER) { InspectorItemBase ppr = getEditor().getInspectorEditor().FindByProperty("setTexto"); if (ppr != null) { if (getEditor().getInspectorEditor().getSelecionado() == ppr) { getEditor().getInspectorEditor().PerformSelect(null); } getEditor().getInspectorEditor().PerformSelect(ppr); if (ppr instanceof InspectorItemExtender) { ((InspectorItemExtender) ppr).ExternalRun(); } } return; } if (itensSelecionados.isEmpty()) { return; } FormaElementar item = itensSelecionados.get(0); int x = 0, y = 0; int inc = 3; if (e.isControlDown()) { inc = 1; } switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: x = -inc; y = 0; break; case KeyEvent.VK_RIGHT: x = inc; y = 0; break; case KeyEvent.VK_UP: x = 0; y = -inc; break; case KeyEvent.VK_DOWN: x = 0; y = inc; break; } if (item.isAncorado()) { //HidePontosOnSelecao(false); e.consume(); } else if (x != 0 || y != 0) { if (e.isShiftDown() && item instanceof Forma) { Rectangle rec = new Rectangle(0, 0, -x, -y); ((Forma) item).DoFormaResize(rec); } else { item.DoRaiseMove(x, y); } superAncorador.Posicione(item); DoBaseReenquadreReposicione(); HidePontosOnSelecao(false); PerformInspector(); e.consume(); } }