java.awt.event.KeyEvent Java Examples
The following examples show how to use
java.awt.event.KeyEvent.
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: Utils.java From netbeans with Apache License 2.0 | 6 votes |
public static void stepChooseComponet( String name, TestData data ) { JFrameOperator installerMain = new JFrameOperator(MAIN_FRAME_TITLE); new JButtonOperator(installerMain, "Customize...").push(); JDialogOperator customizeInstallation = new JDialogOperator("Customize Installation"); JListOperator featureList = new JListOperator(customizeInstallation); featureList.selectItem(name); featureList.pressKey(KeyEvent.VK_SPACE); // Check prelude data.m_bPreludePresents = ( -1 != featureList.findItemIndex( "Prelude" ) ); new JButtonOperator(customizeInstallation, "OK").push(); }
Example #2
Source File: PortecleJDialog.java From portecle with GNU General Public License v2.0 | 6 votes |
/** * Get cancel button. * * @return */ protected JButton getCancelButton() { Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }; JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text")); jbCancel.addActionListener(cancelAction); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_KEY); jbCancel.getActionMap().put(ESC_KEY, cancelAction); return jbCancel; }
Example #3
Source File: Generator.java From marathonv5 with Apache License 2.0 | 6 votes |
private List<Integer> tryRobotWith(Robot robot, List<Integer> asciiKeycodes, boolean withShift) { List<Integer> succeeded = new ArrayList<Integer>(); for (Integer keyCode : asciiKeycodes) { try { if (withShift) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(keyCode); robot.keyRelease(keyCode); succeeded.add(keyCode); } catch (Throwable t) { } finally { if (withShift) { robot.keyRelease(KeyEvent.VK_SHIFT); } } } return succeeded; }
Example #4
Source File: bug4983388.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (UnsupportedLookAndFeelException | ClassNotFoundException ex) { System.err.println("GTKLookAndFeel is not supported on this platform. Using defailt LaF for this platform."); } SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(); } }); Robot robot = new Robot(); Util.hitMnemonics(robot, KeyEvent.VK_F); toolkit.realSync(); if (!bMenuSelected) { throw new RuntimeException("shortcuts on menus do not work"); } }
Example #5
Source File: KeyboardState.java From Repeat with Apache License 2.0 | 6 votes |
public KeyboardState changeWith(KeyStroke stroke) { int key = stroke.getKey(); boolean pressed = stroke.isPressed(); if (key == KeyEvent.VK_SHIFT) { return withShiftLocked(pressed); } else if (key == KeyEvent.VK_NUM_LOCK) { return withNumslock(pressed); } else if (key == KeyEvent.VK_CAPS_LOCK) { return withCapslock(pressed); } else if (key == KeyEvent.VK_SCROLL_LOCK) { return withScrollLock(pressed); } return this; }
Example #6
Source File: GameWindow.java From dungeon with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Handles a key press in the text field. This method checks for a command history access by the keys UP, DOWN, or TAB * and, if this is the case, processes this query. * * @param event the KeyEvent. */ private void textFieldKeyPressed(KeyEvent event) { int keyCode = event.getKeyCode(); if (isUpDownOrTab(keyCode)) { // Check if the event is of interest. GameState gameState = Game.getGameState(); if (gameState != null) { CommandHistory commandHistory = gameState.getCommandHistory(); if (keyCode == KeyEvent.VK_UP) { textField.setText(commandHistory.getCursor().moveUp().getSelectedCommand()); } else if (keyCode == KeyEvent.VK_DOWN) { textField.setText(commandHistory.getCursor().moveDown().getSelectedCommand()); } else if (keyCode == KeyEvent.VK_TAB) { // Using the empty String to get the last similar command will always retrieve the last command. // Therefore, there is no need to check if there is something in the text field. String lastSimilarCommand = commandHistory.getLastSimilarCommand(getTrimmedTextFieldText()); if (lastSimilarCommand != null) { textField.setText(lastSimilarCommand); } } } } }
Example #7
Source File: AWTKeyStroke.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns the integer constant for the KeyEvent.VK field named * <code>key</code>. This will throw an * <code>IllegalArgumentException</code> if <code>key</code> is * not a valid constant. */ private static int getVKValue(String key) { VKCollection vkCollect = getVKCollection(); Integer value = vkCollect.findCode(key); if (value == null) { int keyCode = 0; final String errmsg = "String formatted incorrectly"; try { keyCode = KeyEvent.class.getField(key).getInt(KeyEvent.class); } catch (NoSuchFieldException nsfe) { throw new IllegalArgumentException(errmsg); } catch (IllegalAccessException iae) { throw new IllegalArgumentException(errmsg); } value = Integer.valueOf(keyCode); vkCollect.put(key, value); } return value.intValue(); }
Example #8
Source File: MenuItemLayoutHelper.java From hottub with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example #9
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 #10
Source File: bug7055065.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowUI(); } }); toolkit.realSync(); clickCell(robot, 1, 1); Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE); toolkit.realSync(); clickColumnHeader(robot, 1); toolkit.realSync(); clickColumnHeader(robot, 1); }
Example #11
Source File: PinPadPanelImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void eventDispatched(AWTEvent event) { if (event instanceof KeyEvent) { KeyEvent key = (KeyEvent)event; if (key.getID() == 401) { if (key.getKeyCode() == 8) { PinPadPanelImpl.this.processBackspace(); } else if (key.getKeyCode() == 10) { PinPadPanelImpl.this.validateGoButton(); if (PinPadPanelImpl.this.btnGo.isEnabled()) { ActionEvent action = new ActionEvent(PinPadPanelImpl.this.btnGo, 1001, PinPadPanelImpl.this.btnGo.getActionCommand(), System.currentTimeMillis(), 16); PinPadPanelImpl.this.actionListenerGoButton.actionPerformed(action); } } else { PinPadPanelImpl.this.processContent(Character.toString(key.getKeyChar())); } } } }
Example #12
Source File: XButtonPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void handleJavaKeyEvent(KeyEvent e) { int id = e.getID(); switch (id) { case KeyEvent.KEY_PRESSED: if (e.getKeyCode() == KeyEvent.VK_SPACE) { pressed=true; armed=true; repaint(); action(e.getWhen(),e.getModifiers()); } break; case KeyEvent.KEY_RELEASED: if (e.getKeyCode() == KeyEvent.VK_SPACE) { pressed = false; armed = false; repaint(); } break; } }
Example #13
Source File: CompletionTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testMultipleModel() { startTest(); EditorOperator eo = new EditorOperator("0-iteratingwithdivs.html"); eo.setCaretPositionToEndOfLine(6); eo.pressKey(KeyEvent.VK_ENTER); eo.insert("<div data-bind=\"text: newVariable, visible: \"></div>"); evt.waitNoEvent(CompletionTest.WAIT_AFTER_PASTE); eo.setCaretPosition("ible:", 0, true); eo.pressKey(KeyEvent.VK_RIGHT); eo.pressKey(KeyEvent.VK_RIGHT); eo.pressKey(KeyEvent.VK_RIGHT); eo.pressKey(KeyEvent.VK_RIGHT); eo.pressKey(KeyEvent.VK_RIGHT); type(eo, " "); eo.typeKey(' ', InputEvent.CTRL_MASK); CompletionInfo completion = getCompletion(); CompletionJListOperator cjo = completion.listItself; checkCompletionItems(cjo, new String[]{"gamesToPlay", "gamesCount", "name", "log", "printLastname", "printName", "window", "Math"}); completion.listItself.hideAll(); type(eo, "p"); eo.typeKey(' ', InputEvent.CTRL_MASK); completion = getCompletion(); cjo = completion.listItself; checkCompletionItems(cjo, new String[]{"printLastname", "printName"}); checkCompletionDoesntContainItems(cjo, new String[]{"log", "name"}); completion.listItself.hideAll(); cleanLine(eo); endTest(); }
Example #14
Source File: VCSCommitPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { boolean ret = super.processKeyBinding(ks, e, condition, pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
Example #15
Source File: bug4458079.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { public void run() { new bug4458079().createAndShowGUI(); } }); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.realSync(); Robot robot = new Robot(); robot.setAutoDelay(50); Util.hitMnemonics(robot, KeyEvent.VK_M); toolkit.realSync(); Thread.sleep(1000); Util.hitKeys(robot, KeyEvent.VK_DOWN); Util.hitKeys(robot, KeyEvent.VK_ENTER); toolkit.realSync(); Thread.sleep(1000); if (!itemASelected) { throw new RuntimeException("Test failed: arrow key traversal in JMenu broken!"); } }
Example #16
Source File: ReportEditor.java From ramus with GNU General Public License v3.0 | 5 votes |
public RemoveComponentAction() { putValue(ACTION_COMMAND_KEY, "Action.RemoveReportSelectedComponents"); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_DELETE, 0)); putValue(SMALL_ICON, new ImageIcon(getClass().getResource( "/com/ramussoft/gui/table/delete.png"))); setEnabled(false); }
Example #17
Source File: CloneCodeViewerAction.java From ghidra with Apache License 2.0 | 5 votes |
public CloneCodeViewerAction(String owner, CodeViewerProvider provider) { super("Code Viewer Clone", owner); this.provider = provider; ImageIcon image = ResourceManager.loadImage("images/camera-photo.png"); setToolBarData( new ToolBarData( image, "zzzz" ) ); setDescription("Create a snapshot (disconnected) copy of this Listing window "); setHelpLocation(new HelpLocation("Snapshots", "Snapshots_Start")); setKeyBindingData( new KeyBindingData( KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK ) ); }
Example #18
Source File: deadKeyMacOSX.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); switch (state) { case 0: if (keyCode != KeyEvent.VK_ALT) { throw new RuntimeException("Alt is not pressed."); } state++; break; case 1: if (keyCode != KeyEvent.VK_DEAD_ACUTE) { throw new RuntimeException("Dead ACUTE is not pressed."); } if (keyChar != 0xB4) { throw new RuntimeException("Pressed char is not dead acute."); } state++; break; case 2: if (keyCode != KeyEvent.VK_A) { throw new RuntimeException("A is not pressed."); } if (keyChar != 0xE1) { throw new RuntimeException("A char does not have ACCUTE accent"); } state++; break; default: throw new RuntimeException("Excessive keyPressed event."); } }
Example #19
Source File: InputContext.java From Bytecoder with Apache License 2.0 | 5 votes |
private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) { try { if (root.nodeExists(inputMethodSelectionKeyPath)) { Preferences node = root.node(inputMethodSelectionKeyPath); int keyCode = node.getInt(inputMethodSelectionKeyCodeName, KeyEvent.VK_UNDEFINED); if (keyCode != KeyEvent.VK_UNDEFINED) { int modifiers = node.getInt(inputMethodSelectionKeyModifiersName, 0); return AWTKeyStroke.getAWTKeyStroke(keyCode, modifiers); } } } catch (BackingStoreException bse) { } return null; }
Example #20
Source File: PS2.java From OberonEmulator with ISC License | 5 votes |
public int[] encodeNative(int location, int keyCode, boolean press, boolean includeCharBased) { int value = vkMap[location][keyCode]; if (value == 0 && vkMap[KeyEvent.KEY_LOCATION_STANDARD][keyCode] != 0) System.out.println("Key " + keyCode + " exists as standard but not as " + location); VK_TYPE type = VK_TYPE.values()[value >> 8]; if (value == 0 || (type == VK_TYPE.CHAR_BASED && !includeCharBased)) return new int[0]; value = value & 0xFF; switch (type) { case CHAR_BASED: case NORMAL: if (press) return new int[] { value }; else return new int[] { 0xF0, value }; case EXTENDED: if (press) return new int[] { 0xE0, value }; else return new int[] { 0xE0, 0xF0, value }; case NUMLOCK_HACK: if (press) return new int[] { 0xE0, 0x12, 0xE0, value }; else return new int[] { 0xE0, 0xF0, value, 0xE0, 0xF0, 0x12 }; case SHIFT_HACK: if (press) return new int[] { 0xE0, 0xF0, 0x12, 0xE0, 0xF0, 0x59, 0xE0, value }; else return new int[] { 0xE0, 0xF0, value }; } return new int[0]; }
Example #21
Source File: bug8057893.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Robot robot = new Robot(); robot.setAutoDelay(50); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); EventQueue.invokeAndWait(() -> { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"}); comboBox.setEditable(true); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if ("comboBoxEdited".equals(e.getActionCommand())) { isComboBoxEdited = true; } } }); frame.add(comboBox); frame.pack(); frame.setVisible(true); comboBox.requestFocusInWindow(); }); toolkit.realSync(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); toolkit.realSync(); if(!isComboBoxEdited){ throw new RuntimeException("ComboBoxEdited event is not fired!"); } }
Example #22
Source File: AWTKeyStroke.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static String getVKText(int keyCode) { VKCollection vkCollect = getVKCollection(); Integer key = Integer.valueOf(keyCode); String name = vkCollect.findName(key); if (name != null) { return name.substring(3); } int expected_modifiers = (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL); Field[] fields = KeyEvent.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { try { if (fields[i].getModifiers() == expected_modifiers && fields[i].getType() == Integer.TYPE && fields[i].getName().startsWith("VK_") && fields[i].getInt(KeyEvent.class) == keyCode) { name = fields[i].getName(); vkCollect.put(name, key); return name.substring(3); } } catch (IllegalAccessException e) { assert(false); } } return "UNKNOWN"; }
Example #23
Source File: EditorDisplayerTest.java From netbeans with Apache License 2.0 | 5 votes |
private void typeKey(final Component target, final int key) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { public void run() { KeyEvent ke = new KeyEvent(target, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, (char) key); target.dispatchEvent(ke); } }); sleep(); }
Example #24
Source File: InplaceEditorNoModifyOnTextChangeContractComboEditorTest.java From netbeans with Apache License 2.0 | 5 votes |
private void dispatchEvent(final KeyEvent ke, final Component comp) throws Exception { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeAndWait(new Runnable() { public void run() { comp.dispatchEvent(ke); } }); } else { comp.dispatchEvent(ke); } sleep(); }
Example #25
Source File: bug5043626.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(); } }); toolkit.realSync(); Util.hitKeys(robot, KeyEvent.VK_HOME); Util.hitKeys(robot, KeyEvent.VK_1); toolkit.realSync(); String test = getText(); if (!"1test".equals(test)) { throw new RuntimeException("Begin line action set cursor inside <head> tag"); } Util.hitKeys(robot, KeyEvent.VK_HOME); Util.hitKeys(robot, KeyEvent.VK_2); toolkit.realSync(); test = getText(); if (!"21test".equals(test)) { throw new RuntimeException("Begin action set cursor inside <head> tag"); } }
Example #26
Source File: ViewLogsSheet.java From bigtable-sql with Apache License 2.0 | 5 votes |
/** * Create user interface. */ private void createUserInterface() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); makeToolWindow(true); final Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(createToolBar(), BorderLayout.NORTH); contentPane.add(createMainPanel(), BorderLayout.CENTER); contentPane.add(createButtonsPanel(), BorderLayout.SOUTH); pack(); final AbstractAction closeAction = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent actionEvent) { performClose(); } }; final KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeStroke, "CloseAction"); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, "CloseAction"); getRootPane().getInputMap(JComponent.WHEN_FOCUSED).put(escapeStroke, "CloseAction"); getRootPane().getActionMap().put("CloseAction", closeAction); }
Example #27
Source File: TableTabCaret.java From Logisim with GNU General Public License v3.0 | 5 votes |
TableTabCaret(TableTab table) { this.table = table; cursorRow = 0; cursorCol = 0; markRow = 0; markCol = 0; table.getTruthTable().addTruthTableListener(listener); table.addMouseListener(listener); table.addMouseMotionListener(listener); table.addKeyListener(listener); table.addFocusListener(listener); InputMap imap = table.getInputMap(); ActionMap amap = table.getActionMap(); AbstractAction nullAction = new AbstractAction() { /** * */ private static final long serialVersionUID = 7932515593155479627L; @Override public void actionPerformed(ActionEvent e) { } }; String nullKey = "null"; amap.put(nullKey, nullAction); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), nullKey); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), nullKey); }
Example #28
Source File: GrailsCommandChooser.java From netbeans with Apache License 2.0 | 5 votes |
private void handleNavigationKeys(KeyEvent evt) { Object actionKey = matchingTaskList.getInputMap().get(KeyStroke.getKeyStrokeForEvent(evt)); // see JavaFastOpen.boundScrollingKey() boolean isListScrollAction = "selectPreviousRow".equals(actionKey) || // NOI18N "selectPreviousRowExtendSelection".equals(actionKey) || // NOI18N "selectNextRow".equals(actionKey) || // NOI18N "selectNextRowExtendSelection".equals(actionKey) || // NOI18N // "selectFirstRow".equals(action) || // NOI18N // "selectLastRow".equals(action) || // NOI18N "scrollUp".equals(actionKey) || // NOI18N "scrollUpExtendSelection".equals(actionKey) || // NOI18N "scrollDown".equals(actionKey) || // NOI18N "scrollDownExtendSelection".equals(actionKey); // NOI18N int selectedIndex = matchingTaskList.getSelectedIndex(); ListModel model = matchingTaskList.getModel(); int modelSize = model.getSize(); // Wrap around if ("selectNextRow".equals(actionKey) && selectedIndex == modelSize - 1) { // NOI18N matchingTaskList.setSelectedIndex(0); matchingTaskList.ensureIndexIsVisible(0); return; } else if ("selectPreviousRow".equals(actionKey) && selectedIndex == 0) { // NOI18N int last = modelSize - 1; matchingTaskList.setSelectedIndex(last); matchingTaskList.ensureIndexIsVisible(last); return; } if (isListScrollAction) { Action action = matchingTaskList.getActionMap().get(actionKey); action.actionPerformed(new ActionEvent(matchingTaskList, 0, (String) actionKey)); evt.consume(); } }
Example #29
Source File: MainFrame.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private void remapCommandOnMac() { // Remap to command v and C on a Mac if (Bither.getGenericApplication() != null && Bither.getGenericApplication().isMac()) { InputMap im = (InputMap) UIManager.get("TextField.focusInputMap"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction); } }
Example #30
Source File: StandardEditingPopupMenu.java From importer-exporter with Apache License 2.0 | 5 votes |
public void init(Component component) { cut = new JMenuItem(); copy = new JMenuItem(); paste = new JMenuItem(); selectAll = new JMenuItem(); cut.setActionCommand((String)TransferHandler.getCutAction().getValue(Action.NAME)); copy.setActionCommand((String)TransferHandler.getCopyAction().getValue(Action.NAME)); paste.setActionCommand((String)TransferHandler.getPasteAction().getValue(Action.NAME)); cut.addActionListener(new TransferActionListener()); copy.addActionListener(new TransferActionListener()); paste.addActionListener(new TransferActionListener()); if (component instanceof JTextComponent) { selectAll.setAction(new TextSelectAllAction()); if (component instanceof JPasswordField) { cut.setEnabled(false); copy.setEnabled(false); } } else if (component instanceof JList) selectAll.setAction(new ListSelectAllAction()); cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); add(cut); add(copy); add(paste); addSeparator(); add(selectAll); }