Java Code Examples for java.awt.event.KeyEvent#VK_HOME

The following examples show how to use java.awt.event.KeyEvent#VK_HOME . 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: SqueakKeyboard.java    From trufflesqueak with MIT License 8 votes vote down vote up
private static int mapSpecialKeyCode(final KeyEvent e) {
    //@formatter:off
    switch(e.getExtendedKeyCode()) {
        case KeyEvent.VK_BACK_SPACE: return 8;
        case KeyEvent.VK_TAB: return 9;
        case KeyEvent.VK_ENTER: return 13;
        case KeyEvent.VK_ESCAPE: return 27;
        case KeyEvent.VK_SPACE: return 32;
        case KeyEvent.VK_PAGE_UP: return 11;
        case KeyEvent.VK_PAGE_DOWN: return 12;
        case KeyEvent.VK_END: return 4;
        case KeyEvent.VK_HOME: return 1;
        case KeyEvent.VK_LEFT: return 28;
        case KeyEvent.VK_UP: return 30;
        case KeyEvent.VK_RIGHT: return 29;
        case KeyEvent.VK_DOWN: return 31;
        case KeyEvent.VK_INSERT: return 5;
        case KeyEvent.VK_DELETE: return 127;
        default: return -1; // Not a special key.
    }
    //@formatter:on
}
 
Example 2
Source File: JPanel_FileBrowser.java    From MobyDroid with Apache License 2.0 6 votes vote down vote up
private void jTable_BrowserKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable_BrowserKeyReleased
    switch (evt.getKeyCode()) {
        case KeyEvent.VK_ENTER:
            //if(currentFile.type.equalsIgnoreCase("desktop") || currentFile.type.equalsIgnoreCase("computer") || currentFile.type.equalsIgnoreCase("hdd") || currentFile.type.equalsIgnoreCase("fdd") || currentFile.type.equalsIgnoreCase("cd") || currentFile.type.equalsIgnoreCase("home") || currentFile.type.equalsIgnoreCase("dir")){
            //    getChildren();
            //}
            int row = jTable_Browser.getSelectedRow();
            MyFile file = fileTableModel.getFile(jTable_Browser.convertRowIndexToModel(row));
            if (file.isDirectory()) {
                updateFilesList(file.getPath());
            }
            break;
        case KeyEvent.VK_BACK_SPACE:
            goUpHandle();
            break;
        case KeyEvent.VK_HOME:
            jTable_Browser.changeSelection(0, 0, false, false);
            break;
        case KeyEvent.VK_END:
            jTable_Browser.changeSelection(jTable_Browser.getRowCount() - 1, 0, false, false);
            break;
        default:
            break;
    }
}
 
Example 3
Source File: JRViewerPanel.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void keyNavigate(KeyEvent evt)
{
	boolean refresh = true;
	switch (evt.getKeyCode())
	{
	case KeyEvent.VK_DOWN:
	case KeyEvent.VK_PAGE_DOWN:
		dnNavigate(evt);
		break;
	case KeyEvent.VK_UP:
	case KeyEvent.VK_PAGE_UP:
		upNavigate(evt);
		break;
	case KeyEvent.VK_HOME:
		homeEndNavigate(0);
		break;
	case KeyEvent.VK_END:
		homeEndNavigate(viewerContext.getPageCount() - 1);
		break;
	default:
		refresh = false;
	}
	
	if (refresh)
	{
		viewerContext.refreshPage();
	}
}
 
Example 4
Source File: KeyboardSupport.java    From CrossMobile with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void reactToReleaseEvent(CEventCallback callback, int vk_event, int modifier) {
    switch (vk_event) {
        case KeyEvent.VK_CONTROL:
            if ((mask & MULTITOUCH.mask) != 0)
                callback.endMultiTouch();
            break;
        case KeyEvent.VK_B:
        case KeyEvent.VK_BACK_SPACE:
            if ((mask & BACK.mask) != 0)
                callback.back();
            break;
        case KeyEvent.VK_P:
        case KeyEvent.VK_SPACE:
            if ((mask & PAUSE.mask) != 0)
                ((DesktopLifecycleBridge) Native.lifecycle()).toggleActivation();
            break;
        case KeyEvent.VK_ESCAPE:
        case KeyEvent.VK_Q:
            if ((mask & QUIT.mask) != 0)
                callback.powerOff();
            break;
        case KeyEvent.VK_M:
            if (modifier == KeyEvent.CTRL_MASK)
                memoryWarning();
            break;
        case KeyEvent.VK_H:
        case KeyEvent.VK_HOME:
            if ((mask & HOME.mask) != 0)
                callback.home();
            break;
        case KeyEvent.VK_LEFT:
            if ((mask & ROTATE.mask) != 0)
                callback.rotateLeft();
            break;
        case KeyEvent.VK_RIGHT:
            if ((mask & ROTATE.mask) != 0)
                callback.rotateRight();
            break;
    }
}
 
Example 5
Source File: JBinaryViewer.java    From freeinternals with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {

    switch (e.getKeyCode()) {
        case KeyEvent.VK_HOME:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getMinimum());
            break;

        case KeyEvent.VK_END:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getMaximum());
            break;

        case KeyEvent.VK_UP:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() - 1);
            break;
        case KeyEvent.VK_DOWN:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() + 1);
            break;

        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_PAGE_UP:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() - JBinaryViewer.this.vBar.getVisibleAmount());
            break;

        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_PAGE_DOWN:
            JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() + JBinaryViewer.this.vBar.getVisibleAmount());
            break;

        default:
            break;
    }
}
 
Example 6
Source File: IPV4Field.java    From lippen-network-tool with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    JTextComponent field = (JTextComponent) e.getComponent();
    int keyCode = e.getKeyCode();
    char keyChar = e.getKeyChar();
    String text = field.getText();
    String selText = field.getSelectedText();
    int caretPos = field.getCaretPosition();
    int textLength = text.length();
    if ((keyCode == KeyEvent.VK_LEFT) && (caretPos == 0)
            && (selText == null)) {
        field.firePropertyChange("Left", 0, 1);
    } else if (((keyCode == KeyEvent.VK_RIGHT)
            && (caretPos == textLength) && (selText == null))
            || ((keyChar == '.') && (!text.isEmpty()) && (selText == null))) {
        field.firePropertyChange("Right", 0, 1);
    } else if ((keyCode == KeyEvent.VK_BACK_SPACE) && (caretPos == 0)
            && (selText == null)) {
        field.firePropertyChange("BackSpace", 0, 1);
    } else if ((keyCode == KeyEvent.VK_DELETE)
            && (caretPos == textLength) && (selText == null)) {
        field.firePropertyChange("Delete", 0, 1);
    } else if (keyCode == KeyEvent.VK_HOME) {
        IPV4Field.this.ipFields[0].unSelectAllWhenFocusGained();
        IPV4Field.this.ipFields[0].requestFocus();
        IPV4Field.this.ipFields[0].setCaretPosition(0);
    } else if (keyCode == KeyEvent.VK_END) {
        int last = IPV4Field.this.ipFields.length - 1;
        textLength = IPV4Field.this.ipFields[last].getText()
                .length();
        IPV4Field.this.ipFields[last]
                .unSelectAllWhenFocusGained();
        IPV4Field.this.ipFields[last].requestFocus();
        IPV4Field.this.ipFields[last]
                .setCaretPosition(textLength);
    } else if ((keyCode == KeyEvent.VK_0 || keyCode == KeyEvent.VK_NUMPAD0) && (caretPos == 0 || (text != null && text.equals(selText)))) {
        field.firePropertyChange("Right", 0, 1);
    } else if (("0123456789".indexOf(keyChar) >= 0)) {
        if (selText == null) {
            int ipInt = (text.length() == 0 ? 0 : Integer
                    .parseInt(text));

            if (ipInt > 25) {
                field.firePropertyChange("Right", 0, 1);
            }
        } else {
            if (field.getSelectionStart() == 2
                    && field.getSelectionEnd() == 3) {
                field.firePropertyChange("Right", 0, 1);
            }
        }
    }
}
 
Example 7
Source File: ListDelegationUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static ActionCallback installKeyboardDelegation(final JComponent focusedComponent, final JList delegateTo) {
  final KeyListener keyListener = new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      final int code = e.getKeyCode();
      final int modifiers = e.getModifiers();
      switch (code) {
        case KeyEvent.VK_UP:
          ScrollingUtil.moveUp(delegateTo, modifiers);
          break;
        case KeyEvent.VK_DOWN:
          ScrollingUtil.moveDown(delegateTo, modifiers);
          break;
        case KeyEvent.VK_HOME:
          ScrollingUtil.moveHome(delegateTo);
          break;
        case KeyEvent.VK_END:
          ScrollingUtil.moveEnd(delegateTo);
          break;
        case KeyEvent.VK_PAGE_UP:
          ScrollingUtil.movePageUp(delegateTo);
          break;
        case KeyEvent.VK_PAGE_DOWN:
          ScrollingUtil.movePageDown(delegateTo);
          break;
      }
    }
  };

  focusedComponent.addKeyListener(keyListener);

  final ActionCallback callback = new ActionCallback();
  callback.doWhenProcessed(() -> focusedComponent.removeKeyListener(keyListener));
  return callback;
}
 
Example 8
Source File: NetAdmin.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if( (e.getKeyCode() != KeyEvent.VK_UP) && (e.getKeyCode() != KeyEvent.VK_DOWN) &&
	    (e.getKeyCode() != KeyEvent.VK_LEFT) && (e.getKeyCode() != KeyEvent.VK_RIGHT) &&
	    (e.getKeyCode() != KeyEvent.VK_HOME) && (e.getKeyCode() != KeyEvent.VK_END) &&
	    (e.getKeyCode() != KeyEvent.VK_PAGE_UP) && (e.getKeyCode() != KeyEvent.VK_PAGE_DOWN) &&
	    ((e.getKeyCode() != KeyEvent.VK_A) || (e.isControlDown() == false)) &&
	    ((e.getKeyCode() != KeyEvent.VK_C) || (e.isControlDown() == false)) &&
	    (!e.isAltDown()) )
	{
		e.consume();
	}
}
 
Example 9
Source File: ListUtil.java    From Zettelkasten with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method retrieves the key-code {@code keyCode} of a released key in the
 * JList {@code list} and checks whether this key was a navigation key (i.e.
 * cursor up/down/left/right or home/end). If so, the method tries to select the next
 * related entry of that JList, according to the pressed key.<br><br>
 * Furthermore, the related content is made visible (scroll rect to visible or ensure
 * index is visible).
 *
 * @param list a reference to the JList where the related key was released
 * @param keyCode the keycode of the released key
 */
public static void navigateThroughList(javax.swing.JList list, int keyCode) {
    if (KeyEvent.VK_LEFT == keyCode || KeyEvent.VK_RIGHT == keyCode) {
        return;
    }
    int selectedRow = list.getSelectedIndex();
    ListModel lm = list.getModel();
    if (-1 == selectedRow) {
        selectedRow = 0;
    }
    switch (keyCode) {
        case KeyEvent.VK_HOME:
            selectedRow = 0;
            break;
        case KeyEvent.VK_END:
            selectedRow = lm.getSize() - 1;
            break;
        case KeyEvent.VK_DOWN:
            if (lm.getSize() > (selectedRow + 1)) {
                selectedRow++;
            }
            break;
        case KeyEvent.VK_UP:
            if (selectedRow > 0) {
                selectedRow--;
            }
            break;
    }
    list.setSelectedIndex(selectedRow);
    list.ensureIndexIsVisible(selectedRow);
}
 
Example 10
Source File: JRViewer.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
protected void keyNavigate(KeyEvent evt)
{
	boolean refresh = true;
	switch (evt.getKeyCode())
	{
	case KeyEvent.VK_DOWN:
	case KeyEvent.VK_PAGE_DOWN:
		dnNavigate(evt);
		break;
	case KeyEvent.VK_UP:
	case KeyEvent.VK_PAGE_UP:
		upNavigate(evt);
		break;
	case KeyEvent.VK_HOME:
		homeEndNavigate(0);
		break;
	case KeyEvent.VK_END:
		homeEndNavigate(jasperPrint.getPages().size() - 1);
		break;
	default:
		refresh = false;
	}
	
	if (refresh)
	{
		refreshPage();
	}
}
 
Example 11
Source File: TableUtils.java    From Zettelkasten with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method retrieves the key-code {@code keyCode} of a released key in
 * the JTable {@code table} and checks whether this key was a navigation key
 * (i.e. cursor up/down/left/right or home/end). If so, the method tries to
 * select the next related entry of that JTable, according to the pressed
 * key.<br><br>
 * Furthermore, the related content is made visible (scroll rect to visible
 * or ensure index is visible).
 *
 * @param table a reference to the JTable where the related key was released
 * @param keyCode the keycode of the released key
 */
public static void navigateThroughList(JTable table, int keyCode) {
    if (KeyEvent.VK_LEFT == keyCode || KeyEvent.VK_RIGHT == keyCode) {
        return;
    }
    int selectedRow = table.getSelectedRow();
    if (-1 == selectedRow) {
        selectedRow = 0;
    }
    switch (keyCode) {
        case KeyEvent.VK_HOME:
            selectedRow = 0;
            break;
        case KeyEvent.VK_END:
            selectedRow = table.getRowCount() - 1;
            break;
        case KeyEvent.VK_DOWN:
            if (table.getRowCount() > (selectedRow + 1)) {
                selectedRow++;
            }
            break;
        case KeyEvent.VK_UP:
            if (selectedRow > 0) {
                selectedRow--;
            }
            break;
    }
    table.getSelectionModel().setSelectionInterval(selectedRow, selectedRow);
    table.scrollRectToVisible(table.getCellRect(selectedRow, 0, false));
}
 
Example 12
Source File: TextAreaReadline.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public void keyPressed(KeyEvent event) {
    int code = event.getKeyCode();
    switch (code) {
        case KeyEvent.VK_TAB:
            completeAction(event);
            break;
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_BACK_SPACE:
            backAction(event);
            break;
        case KeyEvent.VK_UP:
            upAction(event);
            break;
        case KeyEvent.VK_DOWN:
            downAction(event);
            break;
        case KeyEvent.VK_ENTER:
            enterAction(event);
            break;
        case KeyEvent.VK_HOME:
            event.consume();
            area.setCaretPosition(startPos);
            break;
        case KeyEvent.VK_D:
            if ((event.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) {
                event.consume();
                inputJoin.send(Channel.LINE, EMPTY_LINE);
            }
            break;
    }

    if (completePopup.isVisible() && code != KeyEvent.VK_TAB
            && code != KeyEvent.VK_UP && code != KeyEvent.VK_DOWN)
        completePopup.setVisible(false);
}
 
Example 13
Source File: TypeInstanceTableDatamodel.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void keyPressedOrTyped(CodeDisplayCoordinate coordinate, KeyEvent event) {
  if (!isEditable(coordinate)) {
    return;
  }
  // Deal with key events in the name or comments fields. These have to be handled differently.

  if (coordinate.getColumn() == COMMENTS_INDEX) {
  } else if (coordinate.getColumn() == NAME_INDEX) {
    if (coordinate.getLine() != 0) {
      // There are no multi-line names, so just bare essential keys are supported here.
      switch (event.getKeyCode()) {
        case 0:
        case KeyEvent.VK_HOME:
          coordinate.setFieldIndex(0);
          break;
        case KeyEvent.VK_END:
          coordinate.setFieldIndex(columns[coordinate.getColumn()].getWidth() - 1);
          break;
        default:
          // No special handling in the default case.
          break;
      }
    } else {
      // In the first line, the name can be changed. Allow this to occur if the caret is next
      // to an existing letter of the name.
      // TODO(thomasdullien): Implement.
    }
  }
}
 
Example 14
Source File: Caret.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	int cols = hex.getMeasures().getColumnCount();
	int rows;
	boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
	switch (e.getKeyCode()) {
	case KeyEvent.VK_UP:
		if (cursor >= cols)
			setDot(cursor - cols, shift);
		break;
	case KeyEvent.VK_LEFT:
		if (cursor >= 1)
			setDot(cursor - 1, shift);
		break;
	case KeyEvent.VK_DOWN:
		if (cursor >= hex.getModel().getFirstOffset() && cursor <= hex.getModel().getLastOffset() - cols) {
			setDot(cursor + cols, shift);
		}
		break;
	case KeyEvent.VK_RIGHT:
		if (cursor >= hex.getModel().getFirstOffset() && cursor <= hex.getModel().getLastOffset() - 1) {
			setDot(cursor + 1, shift);
		}
		break;
	case KeyEvent.VK_HOME:
		if (cursor >= 0) {
			int dist = (int) (cursor % cols);
			if (dist == 0)
				setDot(0, shift);
			else
				setDot(cursor - dist, shift);
			break;
		}
	case KeyEvent.VK_END:
		if (cursor >= 0) {
			HexModel model = hex.getModel();
			long dest = (cursor / cols * cols) + cols - 1;
			if (model != null) {
				long end = model.getLastOffset();
				if (dest > end || dest == cursor)
					dest = end;
				setDot(dest, shift);
			} else {
				setDot(dest, shift);
			}
		}
		break;
	case KeyEvent.VK_PAGE_DOWN:
		rows = hex.getVisibleRect().height / hex.getMeasures().getCellHeight();
		if (rows > 2)
			rows--;
		if (cursor >= 0) {
			long max = hex.getModel().getLastOffset();
			if (cursor + rows * cols <= max) {
				setDot(cursor + rows * cols, shift);
			} else {
				long n = cursor;
				while (n + cols < max)
					n += cols;
				setDot(n, shift);
			}
		}
		break;
	case KeyEvent.VK_PAGE_UP:
		rows = hex.getVisibleRect().height / hex.getMeasures().getCellHeight();
		if (rows > 2)
			rows--;
		if (cursor >= rows * cols)
			setDot(cursor - rows * cols, shift);
		else if (cursor >= cols)
			setDot(cursor % cols, shift);
		break;
	}
}
 
Example 15
Source File: TableTabCaret.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (cursorRow < 0)
		return;
	TruthTable model = table.getTruthTable();
	int rows = model.getRowCount();
	int inputs = model.getInputColumnCount();
	int outputs = model.getOutputColumnCount();
	int cols = inputs + outputs;
	boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
	switch (e.getKeyCode()) {
	case KeyEvent.VK_UP:
		setCursor(cursorRow - 1, cursorCol, shift);
		break;
	case KeyEvent.VK_LEFT:
		setCursor(cursorRow, cursorCol - 1, shift);
		break;
	case KeyEvent.VK_DOWN:
		setCursor(cursorRow + 1, cursorCol, shift);
		break;
	case KeyEvent.VK_RIGHT:
		setCursor(cursorRow, cursorCol + 1, shift);
		break;
	case KeyEvent.VK_HOME:
		if (cursorCol == 0)
			setCursor(0, 0, shift);
		else
			setCursor(cursorRow, 0, shift);
		break;
	case KeyEvent.VK_END:
		if (cursorCol == cols - 1)
			setCursor(rows - 1, cols - 1, shift);
		else
			setCursor(cursorRow, cols - 1, shift);
		break;
	case KeyEvent.VK_PAGE_DOWN:
		rows = table.getVisibleRect().height / table.getCellHeight();
		if (rows > 2)
			rows--;
		setCursor(cursorRow + rows, cursorCol, shift);
		break;
	case KeyEvent.VK_PAGE_UP:
		rows = table.getVisibleRect().height / table.getCellHeight();
		if (rows > 2)
			rows--;
		setCursor(cursorRow - rows, cursorCol, shift);
		break;
	}
}
 
Example 16
Source File: TextFieldCaret.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
	if ((e.getModifiersEx() & ign) != 0)
		return;
	switch (e.getKeyCode()) {
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_KP_LEFT:
		if (pos > 0)
			--pos;
		break;
	case KeyEvent.VK_RIGHT:
	case KeyEvent.VK_KP_RIGHT:
		if (pos < curText.length())
			++pos;
		break;
	case KeyEvent.VK_HOME:
		pos = 0;
		break;
	case KeyEvent.VK_END:
		pos = curText.length();
		break;
	case KeyEvent.VK_ESCAPE:
	case KeyEvent.VK_CANCEL:
		cancelEditing();
		break;
	case KeyEvent.VK_CLEAR:
		curText = "";
		pos = 0;
		break;
	case KeyEvent.VK_ENTER:
		stopEditing();
		break;
	case KeyEvent.VK_BACK_SPACE:
		if (pos > 0) {
			curText = curText.substring(0, pos - 1) + curText.substring(pos);
			--pos;
			field.setText(curText);
		}
		break;
	case KeyEvent.VK_DELETE:
		if (pos < curText.length()) {
			curText = curText.substring(0, pos) + curText.substring(pos + 1);
			field.setText(curText);
		}
		break;
	case KeyEvent.VK_INSERT:
	case KeyEvent.VK_COPY:
	case KeyEvent.VK_CUT:
	case KeyEvent.VK_PASTE:
		// TODO: enhance label editing
		break;
	default:
		; // ignore
	}
}
 
Example 17
Source File: MethodChooser.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    int code = e.getKeyCode();
    boolean consumeEvent = true;
    switch (code) {
        case KeyEvent.VK_ENTER:
        case KeyEvent.VK_SPACE:
            // selection confirmed
            releaseUI(true);
            break;
        case KeyEvent.VK_ESCAPE:
            // action canceled
            releaseUI(false);
            break;
        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_DOWN:
        case KeyEvent.VK_TAB:
            selectedIndex++;
            if (selectedIndex == segments.length) {
                selectedIndex = 0;
            }
            requestRepaint();
            break;
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_UP:
            selectedIndex--;
            if (selectedIndex < 0) {
                selectedIndex = segments.length - 1;
            }
            requestRepaint();
            break;
        case KeyEvent.VK_HOME:
            selectedIndex = 0;
            requestRepaint();
            break;
        case KeyEvent.VK_END:
            selectedIndex = segments.length - 1;
            requestRepaint();
            break;
        default:
            int mods = e.getModifiersEx();
            for (int x = 0; x < stopEvents.length; x++) {
                if (stopEvents[x].getKeyCode() == code &&
                        (stopEvents[x].getModifiers() & mods) == stopEvents[x].getModifiers()) {
                    releaseUI(false);
                    consumeEvent = false;
                    break;
                }
            }
            for (int x = 0; x < confirmEvents.length; x++) {
                if (confirmEvents[x].getKeyCode() == code &&
                        (confirmEvents[x].getModifiers() & mods) == confirmEvents[x].getModifiers()) {
                    releaseUI(true);
                    break;
                }
            }
    }
    if (consumeEvent) {
        e.consume();
    }
}
 
Example 18
Source File: ReflectCompletionDialog.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
private void jTxtItemKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtItemKeyPressed

		int i = jLstItems.getSelectedIndex();
		switch (evt.getKeyCode()) {
			case KeyEvent.VK_ESCAPE:
				target.setCaretPosition(target.getSelectionEnd());
				setVisible(false);
				return;
			case KeyEvent.VK_DOWN:
				i++;
				break;
			case KeyEvent.VK_UP:
				i--;
				break;
			case KeyEvent.VK_HOME:
				i = 0;
				break;
			case KeyEvent.VK_END:
				i = jLstItems.getModel().getSize() - 1;
				break;
			case KeyEvent.VK_PAGE_DOWN:
				i += jLstItems.getVisibleRowCount();
				break;
			case KeyEvent.VK_PAGE_UP:
				i -= jLstItems.getVisibleRowCount();
				break;
		}

		if (escapeChars.indexOf(evt.getKeyChar()) >= 0) {
			String result = getSelection();
			char pressed = evt.getKeyChar();
			// we need to just accept ENTER, and replace the tab with a single
			// space
			if (pressed != '\n') {
				result += (pressed == '\t') ? ' ' : pressed;
			}
			target.replaceSelection(result);
			setVisible(false);
		} else {
			// perform bounds checks for i
			if (i >= jLstItems.getModel().getSize()) {
				i = jLstItems.getModel().getSize() - 1;
			}
			if (i < 0) {
				i = 0;
			}
			jLstItems.setSelectedIndex(i);
			jLstItems.ensureIndexIsVisible(i);
		}
    }
 
Example 19
Source File: VncClientPacketSender.java    From cosmic with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(final int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 20
Source File: JavaRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(int keycode) {
    if (keycode == KeyEvent.VK_TAB) {
        return "Tab";
    }
    if (keycode == KeyEvent.VK_CONTROL) {
        return "Ctrl";
    }
    if (keycode == KeyEvent.VK_ALT) {
        return "Alt";
    }
    if (keycode == KeyEvent.VK_SHIFT) {
        return "Shift";
    }
    if (keycode == KeyEvent.VK_META) {
        return "Meta";
    }
    if (keycode == KeyEvent.VK_SPACE) {
        return "Space";
    }
    if (keycode == KeyEvent.VK_BACK_SPACE) {
        return "Backspace";
    }
    if (keycode == KeyEvent.VK_HOME) {
        return "Home";
    }
    if (keycode == KeyEvent.VK_END) {
        return "End";
    }
    if (keycode == KeyEvent.VK_DELETE) {
        return "Delete";
    }
    if (keycode == KeyEvent.VK_PAGE_UP) {
        return "Pageup";
    }
    if (keycode == KeyEvent.VK_PAGE_DOWN) {
        return "Pagedown";
    }
    if (keycode == KeyEvent.VK_UP) {
        return "Up";
    }
    if (keycode == KeyEvent.VK_DOWN) {
        return "Down";
    }
    if (keycode == KeyEvent.VK_LEFT) {
        return "Left";
    }
    if (keycode == KeyEvent.VK_RIGHT) {
        return "Right";
    }
    if (keycode == KeyEvent.VK_ENTER) {
        return "Enter";
    }
    return KeyEvent.getKeyText(keycode);
}