Examples of KeyStroke


Examples of javax.swing.KeyStroke

        }

        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, JComponent.WHEN_IN_FOCUSED_WINDOW);
          }
        }
        else if (event.getPropertyName().equals(ActionDowngrade.MNEMONIC_KEY))
        {
View Full Code Here

Examples of javax.swing.KeyStroke

      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, JComponent.WHEN_IN_FOCUSED_WINDOW);
      }
    }
  }
View Full Code Here

Examples of javax.swing.KeyStroke

        }

        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, JComponent.WHEN_IN_FOCUSED_WINDOW);
          }
        }
        else if (event.getPropertyName().equals(ActionDowngrade.MNEMONIC_KEY))
        {
View Full Code Here

Examples of javax.swing.KeyStroke

    // Add a popup menu to copy to the clipboard...
    this.copyPopupMenu = new JPopupMenu();

    final String label = bundleSupport.getString("system-properties-panel.popup-menu.copy");
    final KeyStroke accelerator = bundleSupport.getKeyStroke("system-properties-panel.popup-menu.copy.accelerator");

    final JMenuItem copyMenuItem = new JMenuItem(label);
    copyMenuItem.setAccelerator(accelerator);
    copyMenuItem.getAccessibleContext().setAccessibleDescription(label);
    copyMenuItem.addActionListener(new CopyAction());
View Full Code Here

Examples of javax.swing.KeyStroke

  }

  public void setProperty(String name, Object value) throws GUIException {
    if ("accelerator".equals(name)) {
      if (value != null && !value.equals("")) {
        KeyStroke stroke = parseKeyStroke((String) value);
        menuItem.setAccelerator(stroke);
      }
    } else if (name.equals("mnemonic")) {
      if (((String) value).length() > 0)
        menuItem.setMnemonic(((String) value).charAt(0));
View Full Code Here

Examples of javax.swing.KeyStroke

     */
    public MyAction()
    {
      putValue(Action.NAME, "Blah");
     // putValue(Action.MNEMONIC_KEY, new Integer('b'));
      final KeyStroke keyStroke =
          KeyStroke.getKeyStroke(KeyEvent.VK_D, getMenuKeyMask());
      putValue(Action.ACCELERATOR_KEY, keyStroke);
    }
View Full Code Here

Examples of javax.swing.KeyStroke

            setText(null);
        }

        String name = (String) action.getValue(action.NAME);
        InputMap inputMap = this.getInputMap(this.WHEN_IN_FOCUSED_WINDOW);
        KeyStroke keyStroke = (KeyStroke) action.getValue(action.ACCELERATOR_KEY);
        inputMap.put(keyStroke, name);

        init(icon);
    }
View Full Code Here

Examples of javax.swing.KeyStroke

    //
    //   Miscelaneous
    //
    protected void registerActions(){
        setRequestFocusEnabled(true);
        KeyStroke ks;
        ks=KeyStroke.getKeyStroke(KeyEvent.VK_L,
                KeyEvent.CTRL_MASK);
        registerKeyboardAction(this, "l",
                ks, WHEN_FOCUSED);
        ks=KeyStroke.getKeyStroke(KeyEvent.VK_W,
View Full Code Here

Examples of javax.swing.KeyStroke

        ImageIcon i = Viewer.instance.resources.getIcon(tag + "Image");
        if (i == null) {
            i = Viewer.instance.resources.getIcon("nullImage");
        }
        putValue(Action.SMALL_ICON, i);
        KeyStroke k = Viewer.instance.resources.getKeyStroke(tag + "Shortcut");
        if (k != null) {
            putValue(Action.ACCELERATOR_KEY, k);
        }
        String tip = Viewer.instance.resources.getStringValue(tag + "Tip");
        putValue(Action.SHORT_DESCRIPTION, tip);
View Full Code Here

Examples of javax.swing.KeyStroke

        ImageIcon i = res.getIcon(resLabel + "Image");
        if (i == null) {
            i = res.getIcon("nullImage");
        }
        action.putValue(Action.SMALL_ICON, i);
        KeyStroke k = res.getKeyStroke(resLabel + "Shortcut");
        if (k != null) {
            action.putValue(Action.ACCELERATOR_KEY, k);
        }
        String tip = res.getStringValue(resLabel + "Tip");
        action.putValue(Action.SHORT_DESCRIPTION, tip);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.