Java Swing KeyStroke removeButtonClickKeystroke(AbstractButton b, KeyStroke key)

Here you can find the source of removeButtonClickKeystroke(AbstractButton b, KeyStroke key)

Description

The reverse Operation of #addButtonClickKeystroke(AbstractButton,KeyStroke,Object) .

License

Open Source License

Parameter

Parameter Description
key The KeyStroke to remove
b the button to work on

Declaration

public static void removeButtonClickKeystroke(AbstractButton b, KeyStroke key) 

Method Source Code

//package com.java2s;
/*/* w ww  . j  ava  2 s  .  com*/
 * funCKit - functional Circuit Kit
 * Copyright (C) 2013  Lukas Elsner <open@mindrunner.de>
 * Copyright (C) 2013  Peter Dahlberg <catdog2@tuxzone.org>
 * Copyright (C) 2013  Julian Stier <mail@julian-stier.de>
 * Copyright (C) 2013  Sebastian Vetter <mail@b4sti.eu>
 * Copyright (C) 2013  Thomas Poxrucker <poxrucker_t@web.de>
 * Copyright (C) 2013  Alexander Treml <alex.treml@directbox.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.swing.AbstractButton;
import javax.swing.ActionMap;

import javax.swing.InputMap;
import javax.swing.JComponent;

import javax.swing.KeyStroke;

public class Main {
    /**
     * The reverse Operation of
     * {@link #addButtonClickKeystroke(AbstractButton, KeyStroke, Object)}.
     * 
     * @param key
     *            The {@link KeyStroke} to remove
     * @param b
     *            the button to work on
     */
    public static void removeButtonClickKeystroke(AbstractButton b, KeyStroke key) {
        InputMap inMap = b.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        ActionMap acMap = b.getActionMap();

        acMap.remove(inMap.get(key));
        inMap.remove(key);

    }
}

Related

  1. registerKeystroke(final JComponent aComponent, final Action aAction, final String aCommandName)
  2. registerTabKey(Container container)
  3. removeAcceleratorFromChildren(Container container, KeyStroke accelerator)
  4. removeAcceleratorFromComponent(JComponent component, KeyStroke accelerator)
  5. removeAcceleratorFromMap(InputMap map, KeyStroke accelerator)
  6. removeKeyBinding(JComponent component, String key)
  7. removeKeyCode(JComponent comp, int keyCode)
  8. removeShortcut(JRootPane rootPane, String command, KeyStroke stroke)
  9. setAcceleratorKey(Action action, KeyStroke acceleratorKey)