Package javax.swing

Examples of javax.swing.KeyStroke


        buttonPanel = new JPanel();
        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
        updateOptions();
        getContentPane().add(buttonPanel, BorderLayout.SOUTH, 1);

        KeyStroke k = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
        Object actionKey = "cancel"; // NOI18N
        getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(k, actionKey);

        Action cancelAction = new AbstractAction() {
View Full Code Here


        System.out.println("got a go...");
        GoButtonPressed();
      }
    };

    KeyStroke keystroke =
      KeyStroke.getKeyStroke('g');//, java.awt.event.InputEvent.CTRL_MASK);
    mainGuiPanel.getInputMap().put(keystroke, "go");
    mainGuiPanel.getActionMap().put("go", goAction);

    Color c = new Color((int)(Math.random() * 127 + 127),
View Full Code Here

       
        frame = f;
    }

    protected JRootPane createRootPane() {
        KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
        KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
       
        JRootPane rootPane = new JRootPane();
        rootPane.registerKeyboardAction(this, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
        rootPane.registerKeyboardAction(this, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
       
View Full Code Here

      final Object    idObj;
      final String    type;
      final int      typeIdx;
      final String[]    hierarchy;
      final String    text;
      final KeyStroke    stroke;
      final OSCMenuNode  n;
      MenuGroup      mg, parent;
      int          argIdx    = 1;
     
      try {
View Full Code Here

   */
  public static final KeyStroke prefsToStroke( String prefsValue )
  {
    if( prefsValue == null ) return null;
    int i = prefsValue.indexOf( ' ' );
    KeyStroke prefsStroke = null;
    try {
      if( i < 0 ) return null;
      prefsStroke = KeyStroke.getKeyStroke( Integer.parseInt( prefsValue.substring( i+1 )),
                          Integer.parseInt( prefsValue.substring( 0, i )));
    }
View Full Code Here

    dispose();
    System.exit(0);
  }

  void setCtrlAccelerator(JMenuItem mi, char acc) {
    KeyStroke ks = KeyStroke.getKeyStroke(acc, 2);
    mi.setAccelerator(ks);
  }
View Full Code Here

public class KeyUtil {
    public static boolean match(Shortcut[] shortcuts, KeyEvent e) {
        for (Shortcut shortcut : shortcuts) {
            if (shortcut instanceof KeyboardShortcut) {
                KeyboardShortcut keyboardShortcut = (KeyboardShortcut) shortcut;
                KeyStroke shortkutKeyStroke = keyboardShortcut.getFirstKeyStroke();
                KeyStroke eventKeyStroke = KeyStroke.getKeyStrokeForEvent(e);
                if (shortkutKeyStroke.equals(eventKeyStroke)) {
                    return true;
                }
            }
        }
View Full Code Here

    public static Shortcut[] getShortcuts(String actionId) {
        return KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
    }

    public static ShortcutSet createShortcutSet(int keyCode, int modifiers) {
        KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
        Shortcut shortcut = new KeyboardShortcut(keyStroke, null);
        return new CustomShortcutSet(shortcut);
    }
View Full Code Here

    // Sets keystroke component of currently selected entry
    private void setShortcut(KeyEvent event)
    {
        if (this.chooser.isBindingSelected())
        {
            KeyStroke input = KeyStroke.getKeyStrokeForEvent(event);

            if (this.isDisablingEnabled
                && input.getKeyCode() == this.disablingKeyCode)
            {
                String action = this.chooser.getSelected().getAction();
                if (this.chooser.getBindings().contains(
                    new BindingEntry(BindingEntry.DISABLED, action)))
                {
View Full Code Here

        return System.getProperty("os.name").startsWith("Mac OS X");
    }

    public static void installKeyBindings() {
        if (isMacOSX()) {
            final KeyStroke copyKeyStroke = KeyStroke.getKeyStroke("meta pressed C");
            final KeyStroke pasteKeyStroke = KeyStroke.getKeyStroke("meta pressed V");
            final KeyStroke cutKeyStroke = KeyStroke.getKeyStroke("meta pressed X");
            final KeyStroke allKeyStroke = KeyStroke.getKeyStroke("meta pressed A");

            InputMap textFieldMap = (InputMap) UIManager.get("TextField.focusInputMap");
            textFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
            textFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
            textFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
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.