Package javax.swing

Examples of javax.swing.KeyStroke


        cmdLine.setLayout(new BorderLayout(2,5));
        cmdLine.add(new JLabel("cmd>"), BorderLayout.WEST);
        cmdText.setText("/");
        cmdLine.add(cmdText, BorderLayout.CENTER);

        KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
        cmdText.getInputMap().put(enterKey, SUBMIT_ACTION);
        cmdText.getActionMap().put(SUBMIT_ACTION, opListener);

        submitButton.addActionListener(opListener);
        cmdLine.add(submitButton, BorderLayout.EAST);
View Full Code Here


            removeActionListener(oldAction);
            oldAction.removePropertyChangeListener(getPropertyChangeHandler());

            final Object o = oldAction.getValue(ActionDowngrade.ACCELERATOR_KEY);
            if (o instanceof KeyStroke) {
                final KeyStroke k = (KeyStroke) o;
                unregisterKeyboardAction(k);
            }
        }
        this.action = newAction;
        if (this.action != null) {
            addActionListener(newAction);
            newAction.addPropertyChangeListener(getPropertyChangeHandler());

            setText((String) (newAction.getValue(Action.NAME)));
            setToolTipText((String) (newAction.getValue(Action.SHORT_DESCRIPTION)));
            setIcon((Icon) newAction.getValue(Action.SMALL_ICON));
            setEnabled(this.action.isEnabled());

            Object o = newAction.getValue(ActionDowngrade.MNEMONIC_KEY);
            if (o != null) {
                if (o instanceof Character) {
                    final Character c = (Character) o;
                    setMnemonic(c.charValue());
                }
                else if (o instanceof Integer) {
                    final Integer c = (Integer) o;
                    setMnemonic(c.intValue());
                }
            }
            o = newAction.getValue(ActionDowngrade.ACCELERATOR_KEY);
            if (o instanceof KeyStroke) {
                final KeyStroke k = (KeyStroke) o;
                registerKeyboardAction(newAction, k, WHEN_IN_FOCUSED_WINDOW);
            }
        }
    }
View Full Code Here

                        getAction().getValue(Action.SHORT_DESCRIPTION));
                }

                final Action ac = getAction();
                if (event.getPropertyName().equals(ActionDowngrade.ACCELERATOR_KEY)) {
                    final KeyStroke oldVal = (KeyStroke) event.getOldValue();
                    if (oldVal != null) {
                        unregisterKeyboardAction
                            (oldVal);
                    }
                    final Object o = ac.getValue(ActionDowngrade.ACCELERATOR_KEY);
                    if (o instanceof KeyStroke) {
                        final KeyStroke k = (KeyStroke) o;
                        registerKeyboardAction(ac, k, WHEN_IN_FOCUSED_WINDOW);
                    }
                }
                else if (event.getPropertyName().equals(ActionDowngrade.MNEMONIC_KEY)) {
                    final Object o = ac.getValue(ActionDowngrade.MNEMONIC_KEY);
View Full Code Here

      if (comp == null) {
        return "";
      }
      final KeyStroke[] keys = comp.getRegisteredKeyStrokes();
      String controlKeyStr = "";
      final KeyStroke postTip = KeyStroke.getKeyStroke(KeyEvent.VK_F1, Event.CTRL_MASK);
      for (final KeyStroke key : keys) {
        // Ignore ToolTipManager postTip action,
        // in swing1.1beta3 and onward
        if (postTip.equals(key)) {
          continue;
        }
        final char c = (char) key.getKeyCode();
        final int mod = key.getModifiers();
        if (mod == InputEvent.CTRL_MASK) {
View Full Code Here

     * <tt>Action</tt>s.
     */
    protected void installKeyboardActions() {

        InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
        KeyStroke key;

        key = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
        inputMap.put(key, SCROLL_RIGHT_ACTION);

        key = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0);
View Full Code Here

                    item = new JMenuItem(((String) m[i]).substring(1));

                    char c = ((String) m[i]).charAt(0);

                    if (c != '-') {
                        KeyStroke key =
                            KeyStroke.getKeyStroke(c, Event.CTRL_MASK);

                        item.setAccelerator(key);
                    }
                } else {
View Full Code Here

      public void actionPerformed(ActionEvent actionEvent) {
        setVisible(false);
      }
    };
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(actionListener, stroke,
        JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
  }
View Full Code Here

        bestLogger.log(TreeLogger.ERROR, "Can't log to file "
            + logFile.getAbsolutePath(), ex);
      }
    }
    logger = bestLogger;
    KeyStroke key = getCommandKeyStroke(KeyEvent.VK_F, false);
    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, "find");
    getActionMap().put("find", new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        showFindBox();
      }
View Full Code Here

        public void onCloseRequest() {
          hideFindBox();
        }
      });
      top.add(closeButton);
      KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
      getInputMap(WHEN_IN_FOCUSED_WINDOW).put(key, "find-cancel");
      key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
      getInputMap(WHEN_IN_FOCUSED_WINDOW).put(key, "find-search");
      getActionMap().put("find-search", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
View Full Code Here

        bestLogger.log(TreeLogger.ERROR, "Can't log to file "
            + logFile.getAbsolutePath(), ex);
      }
    }
    logger = bestLogger;
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F,
        InputEvent.CTRL_DOWN_MASK);
    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, "find");
    getActionMap().put("find", new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        showFindBox();
View Full Code Here

TOP

Related Classes of javax.swing.KeyStroke

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.