Java 类javax.swing.InputMap 实例源码

项目:incubator-netbeans    文件:AddModulePanel.java   
private static void exchangeCommands(String[][] commandsToExchange,
        final JComponent target, final JComponent source) {
    InputMap targetBindings = target.getInputMap();
    KeyStroke[] targetBindingKeys = targetBindings.allKeys();
    ActionMap targetActions = target.getActionMap();
    InputMap sourceBindings = source.getInputMap();
    ActionMap sourceActions = source.getActionMap();
    for (int i = 0; i < commandsToExchange.length; i++) {
        String commandFrom = commandsToExchange[i][0];
        String commandTo = commandsToExchange[i][1];
        final Action orig = targetActions.get(commandTo);
        if (orig == null) {
            continue;
        }
        sourceActions.put(commandTo, new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                orig.actionPerformed(new ActionEvent(target, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()));
            }
        });
        for (int j = 0; j < targetBindingKeys.length; j++) {
            if (targetBindings.get(targetBindingKeys[j]).equals(commandFrom)) {
                sourceBindings.put(targetBindingKeys[j], commandTo);
            }
        }
    }
}
项目:incubator-netbeans    文件:OutlineView.java   
private void removeDefaultCutCopyPaste(InputMap map) {
    putActionDelegate(map, KeyStroke.getKeyStroke("control C")); // NOI18N
    map.put(KeyStroke.getKeyStroke("control V"), "none"); // NOI18N
    map.put(KeyStroke.getKeyStroke("control X"), "none"); // NOI18N
    putActionDelegate(map, KeyStroke.getKeyStroke("COPY")); // NOI18N
    map.put(KeyStroke.getKeyStroke("PASTE"), "none"); // NOI18N
    map.put(KeyStroke.getKeyStroke("CUT"), "none"); // NOI18N

    if (Utilities.isMac()) {
        putActionDelegate(map, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK)); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.META_MASK), "none"); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK), "none"); // NOI18N
    } else {
        putActionDelegate(map, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK), "none"); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK), "none"); // NOI18N
    }
}
项目:incubator-netbeans    文件:Preview.java   
private void populateInputMap(InputMap inputMap) {
    inputMap.put(KeyStroke.getKeyStroke('k'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('K'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('+'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('='), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('g'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('G'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('-'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('_'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('l'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('L'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('*'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('f'), FIRST);
    inputMap.put(KeyStroke.getKeyStroke('F'), FIRST);
    inputMap.put(KeyStroke.getKeyStroke('/'), FIRST);
}
项目:incubator-netbeans    文件:CategoryList.java   
private void initActions() {
    InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_ENTER, 0, false ), "defaultAction" );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK, false ), "popup" );

    ActionMap map = getActionMap();
    map.put( "defaultAction", new DefaultAction( this ) );
    map.put( "popup", new PopupAction() );
    map.put( "selectPreviousRow", new MoveFocusAction( map.get( "selectPreviousRow" ), false ) );
    map.put( "selectNextRow", new MoveFocusAction( map.get( "selectNextRow" ), true ) );
    map.put( "selectPreviousColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectPreviousColumn" ), false ), false ) );
    map.put( "selectNextColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectNextColumn" ), true ), true ) );
    Node categoryNode = category.getLookup().lookup(org.openide.nodes.Node.class);
    if( null != categoryNode )
        map.put( "paste", new Utils.PasteItemAction( categoryNode ) );
    else
        map.remove( "paste" );
    map.put( "copy", new CutCopyAction( true ) );
    map.put( "cut", new CutCopyAction( false ) );
}
项目:jdk8u-jdk    文件:XTextAreaPeer.java   
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
项目:incubator-netbeans    文件:FindInQueryBar.java   
FindInQueryBar(FindInQuerySupport support) {
    this.support = support;
    initComponents();
    lastSearchModel = new DefaultComboBoxModel();
    findCombo.setModel(lastSearchModel);
    findCombo.setSelectedItem(""); // NOI18N
    initialized = true;
    addComboEditorListener();
    InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    String closeKey = "close"; // NOI18N
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), closeKey);
    getActionMap().put(closeKey, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FindInQueryBar.this.support.cancel();
        }
    });
}
项目:Logisim    文件:CanvasPane.java   
public CanvasPane(CanvasPaneContents contents) {
    super((Component) contents);
    this.contents = contents;
    this.listener = new Listener();
    this.zoomModel = null;
    // avoid mooving with arrows / pg up down
    InputMap im = this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.put(KeyStroke.getKeyStroke("UP"), "none");
    im.put(KeyStroke.getKeyStroke("DOWN"), "none");
    im.put(KeyStroke.getKeyStroke("LEFT"), "none");
    im.put(KeyStroke.getKeyStroke("RIGHT"), "none");
    im.put(KeyStroke.getKeyStroke("PAGE_DOWN"), "none");
    im.put(KeyStroke.getKeyStroke("PAGE_UP"), "none");
    // if (MacCompatibility.mrjVersion >= 0.0) {
    // i don't want the scrollabar you'll move the pane by dragging with poke tool
    setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    // }

    addComponentListener(listener);
    contents.setCanvasPane(this);
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JtableUtils.java   
/**
 * Adds input action map for the tmodel<p>
 * needed as <code>OnKeyPress Edit</code> in autosuggest overriding the
 * basic <code>Delete</code> key press
 *
 * @param table the target tmodel
 */
private static void clearTableSelectionOnDelete(final JTable table) {
    InputMap inputMap = table.getInputMap(WHEN_FOCUSED);
    ActionMap actionMap = table.getActionMap();
    inputMap.put(Keystroke.DELETE, "delete");
    actionMap.put("delete", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelEditing(table);
            ClearSelection(table);
        }

    });
}
项目:incubator-netbeans    文件:QueryBuilder.java   
/** Opened for the first time */
   @Override
   protected void componentOpened() {

Log.getLogger().entering("QueryBuilder", "componentOpened");

       activateActions();
       ActionMap map = getActionMap();
       InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
       installActions(map, keys);

       // QueryBuilder does not need to listen to VSE, because it will notify us
       // directly if something changes. The SqlCommandCustomizer needs to listen 
       // to VSE, because that's the only way it is notified of changes to the command 
       // sqlStatement.addPropertyChangeListener(sqlStatementListener) ;
       // vse.addPropertyChangeListener(sqlStatementListener) ;

       // do NOT force a parse here.  It's done in componentShowing().
       // populate( sqlStatement.getCommand()) ;
   }
项目:hearthstone    文件:EscolherCard.java   
private void inserirAtalhos() {
    InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelar");

    getRootPane().getActionMap().put("cancelar", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            jPanelCards.removeAll();
            dispose();
        }
    });
}
项目:incubator-netbeans    文件:CheckTreeView.java   
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {

    setFocusable( false );

    CheckListener l = new CheckListener();
    tree.addMouseListener( l );
    tree.addKeyListener( l );

    CheckRenderer check = new CheckRenderer();
    tree.setCellRenderer( check );
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.setShowsRootHandles(false);

    InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
    if( null != input )
        input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );

    setBorder( UIManager.getBorder("ScrollPane.border") );
}
项目:incubator-netbeans    文件:BookmarksView.java   
BookmarksView() {
//        getActionMap().put("rename", SystemAction.get(RenameAction.class));
        nodeTree = new BookmarksNodeTree();
        explorerManager = new ExplorerManager();
        explorerManager.setRootContext(nodeTree.rootNode());
        ActionMap actionMap = getActionMap();
        actionMap.put("delete", ExplorerUtils.actionDelete(explorerManager, false)); //NOI18N
        associateLookup(ExplorerUtils.createLookup(explorerManager, actionMap));
        explorerManager.addPropertyChangeListener(this);

        // Ctrl+T will toggle the tree/table view
        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK), "toggle-view"); //NOI18N
        actionMap.put("toggle-view", new AbstractAction() { //NOI18N
            @Override
            public void actionPerformed(ActionEvent e) {
                setTreeViewVisible(!treeViewShowing);
            }
        });
        setIcon(ImageUtilities.loadImage("org/netbeans/modules/editor/bookmarks/resources/bookmark_16.png")); // NOI18N
    }
项目:incubator-netbeans    文件:SearchUtils.java   
public KeyStroke registerAction(String actionKey, Action action, ActionMap actionMap, InputMap inputMap) {
    KeyStroke ks = null;

    if (FIND_ACTION_KEY.equals(actionKey)) {
        ks = KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK);
    } else if (FIND_NEXT_ACTION_KEY.equals(actionKey)) {
        ks = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0);
    } else if (FIND_PREV_ACTION_KEY.equals(actionKey)) {
        ks = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_MASK);
    } else if (FIND_SEL_ACTION_KEY.equals(actionKey)) {
        ks = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.CTRL_MASK);
    }

    if (ks != null) {
        actionMap.put(actionKey, action);
        inputMap.put(ks, actionKey);
    }

    return ks;
}
项目:Tarski    文件:EditorKeyboardHandler.java   
/**
 * Return JTree's input map.
 */
protected InputMap getInputMap(int condition)
{
    InputMap map = super.getInputMap(condition);

    if (condition == JComponent.WHEN_FOCUSED && map != null)
    {
        map.put(KeyStroke.getKeyStroke("control S"), "save");
        map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs");
        map.put(KeyStroke.getKeyStroke("control N"), "new");
        map.put(KeyStroke.getKeyStroke("control O"), "open");

        map.put(KeyStroke.getKeyStroke("control Z"), "undo");
        map.put(KeyStroke.getKeyStroke("control Y"), "redo");
        map
                .put(KeyStroke.getKeyStroke("control shift V"),
                        "selectVertices");
        map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
    }

    return map;
}
项目:incubator-netbeans    文件:IssuePanel.java   
private void initDefaultButton() {
    if(Boolean.getBoolean("bugtracking.suppressActionKeys")) {
        return;
    }
    InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "submit"); // NOI18N
    ActionMap actionMap = getActionMap();
    Action submitAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (submitButton.isEnabled()) {
                submitButtonActionPerformed(null);
            }
        }
    };
    actionMap.put("submit", submitAction); // NOI18N
}
项目:OpenJSharp    文件:XTextFieldPeer.java   
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
项目:incubator-netbeans    文件:NbEditorToolBar.java   
private void installNoOpActionMappings(){
    InputMap im = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    // cut
    KeyStroke[] keys = findEditorKeys(DefaultEditorKit.cutAction, KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    for (int i = 0; i < keys.length; i++) {
        im.put(keys[i], NOOP_ACTION_KEY);
    }
    // copy
    keys = findEditorKeys(DefaultEditorKit.copyAction, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
    for (int i = 0; i < keys.length; i++) {
        im.put(keys[i], NOOP_ACTION_KEY);
    }
    // delete
    keys = findEditorKeys(DefaultEditorKit.deleteNextCharAction, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); //NOI18N
    for (int i = 0; i < keys.length; i++) {
        im.put(keys[i], NOOP_ACTION_KEY);
    }
    // paste
    keys = findEditorKeys(DefaultEditorKit.pasteAction, KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));
    for (int i = 0; i < keys.length; i++) {
        im.put(keys[i], NOOP_ACTION_KEY);
    }

    getActionMap().put(NOOP_ACTION_KEY, NOOP_ACTION);
}
项目:incubator-netbeans    文件:FindBar.java   
public FindBar(FindSupport support) {
    this.support = support;
    initComponents();
    lastSearchModel = new DefaultComboBoxModel();
    findCombo.setModel(lastSearchModel);
    findCombo.setSelectedItem(""); // NOI18N
    initialized = true;
    addComboEditorListener();
    InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    String closeKey = "close"; // NOI18N
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), closeKey);
    getActionMap().put(closeKey, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FindBar.this.support.cancel();
        }
    });
}
项目:marathonv5    文件:JavaElementPropertyAccessor.java   
private String getKeyStrokeFor(String action) {
    JSONArray r = new JSONArray();
    if (component instanceof JComponent) {
        InputMap inputMap = ((JComponent) component).getInputMap();
        KeyStroke[] allKeys = inputMap.allKeys();
        for (KeyStroke ks : allKeys) {
            if (action.equals(inputMap.get(ks))) {
                r.put(ks.toString());
            }
        }
    }
    if (r.length() > 0) {
        return r.toString();
    }
    return null;
}
项目:marathonv5    文件:DeviceKBTest.java   
private JavaAgentKeys getOSKey() {
    KeyStroke selectall = null;
    InputMap inputMap = new JTextField().getInputMap();
    KeyStroke[] allKeys = inputMap.allKeys();
    for (KeyStroke keyStroke : allKeys) {
        Object object = inputMap.get(keyStroke);
        if (object.equals("select-all")) {
            selectall = keyStroke;
            break;
        }
    }
    if ((selectall.getModifiers() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
        return JavaAgentKeys.CONTROL;
    }
    if ((selectall.getModifiers() & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK) {
        return JavaAgentKeys.META;
    }
    throw new RuntimeException("Which key?");
}
项目:marathonv5    文件:JTextFieldTest.java   
public void checkKeystrokesForActions() throws Throwable {
    StringBuilder sb = new StringBuilder();
    driver = new JavaDriver();
    WebElement textField = driver.findElement(By.cssSelector("text-field"));
    JTextField f = new JTextField();
    InputMap inputMap = f.getInputMap();
    KeyStroke[] allKeys = inputMap.allKeys();
    for (KeyStroke keyStroke : allKeys) {
        Object object = inputMap.get(keyStroke);
        try {
            OSUtils.getKeysFor(textField, object.toString());
        } catch (Throwable t) {
            sb.append("failed for(" + object + "): " + keyStroke);
        }
    }
    AssertJUnit.assertEquals("", sb.toString());
}
项目:ObsidianSuite    文件:ObsidianAnimator.java   
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{       
    FMLInterModComms.sendRuntimeMessage(MODID, "VersionChecker", "addVersionCheck", VERSION_LINK);

    instance = this;        
    proxy.init();

       EventHandler eventHandler = new EventHandler();
       MinecraftForge.EVENT_BUS.register(eventHandler);

       if(FMLCommonHandler.instance().getEffectiveSide().isClient())
           FMLCommonHandler.instance().bus().register(eventHandler);

       //Minecraft.getMinecraft().gameSettings.showInventoryAchievementHint = false;
       Minecraft.getMinecraft().gameSettings.saveOptions();

       //Stop space from activating buttons, allowing it to be used for adding keyframes in the timeline.
       InputMap im = (InputMap)UIManager.get("Button.focusInputMap");
       im.put(KeyStroke.getKeyStroke("pressed SPACE"), "none");
       im.put(KeyStroke.getKeyStroke("released SPACE"), "none");
}
项目:openjdk-jdk10    文件:XTextFieldPeer.java   
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
项目:JavaGraph    文件:Groove.java   
/** Converts an action map to a string representation. */
static public String toString(InputMap im) {
    StringBuilder result = new StringBuilder();
    LinkedHashMap<Object,Object> map = new LinkedHashMap<>();
    for (KeyStroke key : im.allKeys()) {
        map.put(key, im.get(key));
    }
    result.append(map);
    result.append('\n');
    InputMap parent = im.getParent();
    if (parent != null) {
        result.append("Parent: ");
        result.append(toString(parent));
    }
    return result.toString();
}
项目:Tarski    文件:KeyboardHandler.java   
/**
 * Return JTree's input map.
 */
@Override
protected InputMap getInputMap(final int condition) {
  final InputMap map = super.getInputMap(condition);

  if (condition == JComponent.WHEN_FOCUSED && map != null) {
    // map.put(KeyStroke.getKeyStroke("control S"), "save");
    // map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs");
    // map.put(KeyStroke.getKeyStroke("control N"), "new");
    // map.put(KeyStroke.getKeyStroke("control O"), "open");
    //
    // map.put(KeyStroke.getKeyStroke("control Z"), "undo");
    // map.put(KeyStroke.getKeyStroke("control Y"), "redo");
    // map.put(KeyStroke.getKeyStroke("control shift V"), "selectVertices");
    // map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
  }

  return map;
}
项目:JuggleMasterPro    文件:ShortcutsJComboBox.java   
/**
 * Constructs
 * 
 * @param objPcontrolJFrame
 */
public ShortcutsJComboBox(ControlJFrame objPcontrolJFrame) {
    this.objGcontrolJFrame = objPcontrolJFrame;
    this.setFont(this.objGcontrolJFrame.getFont());
    this.setOpaque(true);
    this.setBackground(Constants.objS_PEN_COLORS_LIGHT_YELLOW_COLOR);
    this.setRenderer(Constants.objS_GRAPHICS_DEFAULT_RENDERER);
    this.setMaximumRowCount(Constants.intS_GRAPHICS_MAXIMUM_COMBO_ROWS_NUMBER);
    this.addPopupMenuListener(this);
    this.addActionListener(this);
    final InputMap objLinputMap = this.getInputMap();
    final ActionMap objLactionMap = this.getActionMap();
    objLinputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), KeyEvent.VK_ENTER);
    objLactionMap.put(KeyEvent.VK_ENTER, new KeysAction(objPcontrolJFrame, KeysAction.bytS_SHORTCUTS_J_COMBO_BOX));
    objLinputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), KeyEvent.VK_SPACE);
    objLactionMap.put(KeyEvent.VK_SPACE, new KeysAction(objPcontrolJFrame, KeysAction.bytS_SHORTCUTS_J_COMBO_BOX, KeyEvent.VK_SPACE));
    objLinputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), KeyEvent.VK_COPY);
    objLactionMap.put(KeyEvent.VK_COPY, new KeysAction(objPcontrolJFrame, KeysAction.bytS_SHORTCUTS_J_COMBO_BOX, KeyEvent.VK_COPY));
}
项目:Decoder-Improved    文件:EncodingSelectionDialog.java   
private void init() {
    // Close the dialog when Esc is pressed
    String cancelName = "cancel";
    InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
    ActionMap actionMap = getRootPane().getActionMap();
    actionMap.put(cancelName, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doClose(RET_CANCEL);
        }
    });

    DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) encodingComboBox.getModel();
    for (Map.Entry<String, Charset> entry : Charset.availableCharsets().entrySet()) {
        if (!"UTF-8".equals(entry.getKey())) {
            comboBoxModel.addElement(entry.getValue().name());
        }
    }
}
项目:pdfjumbler    文件:PdfJumbler.java   
private static void registerAccelerators(JComponent component, Action... actions) {
    InputMap inputMap = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap actionMap = component.getActionMap();
    for (Action action : actions) {
        inputMap.put((KeyStroke)action.getValue(Action.ACCELERATOR_KEY), action);
        actionMap.put(action, action);
    }
}
项目:incubator-netbeans    文件:TreeList.java   
/**
 * Right-arrow key expands a row, left-arrow collapses a row, enter invokes
 * row's default action (if any).
 */
private void initKeysAndActions() {
    unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0));
    unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0));
    unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK));

    expandAction = new ExpandAction();
    collapseAction = new CollapseAction();
    defaultAction = new DefaultAction();
    showPopupAction = new ShowPopupAction();

    InputMap imp = getInputMap();
    InputMap impAncestor = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap am = getActionMap();

    imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), ACTION_EXPAND);
    imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), ACTION_COLLAPSE);
    imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ACTION_DEFAULT);
    imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK), ACTION_SHOW_POPUP);

    impAncestor.remove(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0));
    impAncestor.remove(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0));
    impAncestor.remove(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    impAncestor.remove(KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK));

    am.put(ACTION_EXPAND, expandAction);
    am.put(ACTION_COLLAPSE, collapseAction);
    am.put(ACTION_DEFAULT, defaultAction);
    am.put(ACTION_SHOW_POPUP, showPopupAction);
}
项目:incubator-netbeans    文件:TransparentSectionButton.java   
private void initActions() {
    InputMap inputMap = getInputMap( WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_LEFT, 0, false ), "collapse" ); //NOI18N
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_RIGHT, 0, false ), "expand" ); //NOI18N

    ActionMap actionMap = getActionMap();
    actionMap.put( "collapse", new ExpandAction( false ) ); //NOI18N
    actionMap.put( "expand", new ExpandAction( true ) ); //NOI18N
}
项目:incubator-netbeans    文件:MultiViewPeer.java   
void initComponents() {
        initActionMap();
        peer.setLayout(new BorderLayout());
        tabs = new TabsComponent(isToolbarVisible());
        peer.add(tabs);
        ActionMap map = peer.getActionMap();
        Action act = new AccessTogglesAction();
        map.put("NextViewAction", new GetRightEditorAction()); //NOI18N
        map.put("PreviousViewAction", new GetLeftEditorAction()); //NOI18N
        map.put("accesstoggles", act); //NOI18N
        InputMap input = peer.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        KeyStroke stroke = KeyStroke.getKeyStroke("control F10"); //NOI18N
        input.put(stroke, "accesstoggles"); //NOI18N
//        stroke = (KeyStroke)new GetLeftEditorAction().getValue(Action.ACCELERATOR_KEY);
//        input.put(stroke, "getLeftEditor");
        input = peer.getInputMap(JComponent.WHEN_FOCUSED);
        input.put(stroke, "accesstoggles"); //NOI18N

        peer.putClientProperty("MultiViewBorderHack.topOffset", new Integer(tabs.getPreferredSize().height - 1));
    }
项目:incubator-netbeans    文件:PopupManager.java   
private void consumeIfKeyPressInActionMap(KeyEvent e) {
    // get popup's registered keyboard actions
    ActionMap am = popup.getActionMap();
    InputMap  im = popup.getInputMap();

    // check whether popup registers keystroke
    // If we consumed key pressed, we need to consume other key events as well:
    KeyStroke ks = KeyStroke.getKeyStrokeForEvent(
            new KeyEvent((Component) e.getSource(),
                         KeyEvent.KEY_PRESSED,
                         e.getWhen(),
                         e.getModifiers(),
                         KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()),
                         e.getKeyChar(),
                         e.getKeyLocation())
    );
    Object obj = im.get(ks);
    if (obj != null && !obj.equals("tooltip-no-action") //NOI18N ignore ToolTipSupport installed actions
    ) {
        // if yes, if there is a popup's action, consume key event
        Action action = am.get(obj);
        if (action != null && action.isEnabled()) {
            // actionPerformed on key press only.
            e.consume();
        }
    }
}
项目:incubator-netbeans    文件:OutlineView.java   
private void putActionDelegate(InputMap map, KeyStroke ks) {
    String binding = COPY_ACTION_DELEGATE+ks.toString();
    Action action = getCopyActionDelegate(map, ks);
    if (action != null) {
        getActionMap().put(binding, action);
        map.put(ks, binding);
    }
}
项目:incubator-netbeans    文件:OutlineView.java   
private Action getCopyActionDelegate(InputMap map, KeyStroke ks) {
    ActionMap am = getActionMap();

    if(map != null && am != null && isEnabled()) {
        Object binding = map.get(ks);
        final Action action = (binding == null) ? null : am.get(binding);
        if (action != null) {
            return new CopyToClipboardAction(action);
        }
    }
    return null;
}
项目:incubator-netbeans    文件:CommitPanel.java   
private void initActions () {
    InputMap inputMap = getInputMap( WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
    ActionMap actionMap = getActionMap();
    Object action = recentLabel.getClientProperty("openAction");
    if (action instanceof Action) {
        inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_R, KeyEvent.ALT_DOWN_MASK, false ), "messageHistory" ); //NOI18N
        actionMap.put("messageHistory", (Action) action); //NOI18N
    }
    action = templatesLabel.getClientProperty("openAction");
    if (action instanceof Action) {
        inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_L, KeyEvent.ALT_DOWN_MASK, false ), "messageTemplate" ); //NOI18N
        actionMap.put("messageTemplate", (Action) action); //NOI18N
    }
}
项目:incubator-netbeans    文件:ETable.java   
@Override
public void actionPerformed(ActionEvent e) {
    if (isEditing() || editorComp != null) {
        removeEditor();
        return;
    } else {
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

        InputMap imp = getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = getRootPane().getActionMap();

        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);
        if (key == null) {
            //Default for NbDialog
            key = "Cancel";
        }
        if (key != null) {
            Action a = am.get(key);
            if (a != null) {
                String commandKey = (String)a.getValue(Action.ACTION_COMMAND_KEY);
                if (commandKey == null) {
                    commandKey = key.toString();
                }
                a.actionPerformed(new ActionEvent(this,
                ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
项目:incubator-netbeans    文件:SectionButton.java   
private void initActions() {
    InputMap inputMap = getInputMap( WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_LEFT, 0, false ), "collapse" ); //NOI18N
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_RIGHT, 0, false ), "expand" ); //NOI18N

    ActionMap actionMap = getActionMap();
    actionMap.put( "collapse", new ExpandAction( false ) ); //NOI18N
    actionMap.put( "expand", new ExpandAction( true ) ); //NOI18N
}
项目:incubator-netbeans    文件:ToolTipManagerEx.java   
/**
    * Removes a component from tooltip control.
    *
    * @param component  a <code>JComponent</code> object to remove
    */
   protected void unregisterComponent(JComponent component) {
       component.removeMouseListener(this);
component.removeMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
项目:Tarski    文件:mxKeyboardHandler.java   
/**
 * Invoked as part from the boilerplate install block.
 */
protected void installKeyboardActions(mxGraphComponent graphComponent) {
  InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  SwingUtilities.replaceUIInputMap(graphComponent, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
      inputMap);

  inputMap = getInputMap(JComponent.WHEN_FOCUSED);
  SwingUtilities.replaceUIInputMap(graphComponent, JComponent.WHEN_FOCUSED, inputMap);
  SwingUtilities.replaceUIActionMap(graphComponent, createActionMap());
}
项目:incubator-netbeans    文件:QueryBuilder.java   
private void installActions(ActionMap map, InputMap keys) {
   /*
    map.put(DefaultEditorKit.copyAction, copyActionPerformer);
    map.put(DefaultEditorKit.cutAction, cutActionPerformer);
    // Paste still done the old way...
    //map.put(DefaultEditorKit.pasteAction, pasteActionPerformer);
    */
    map.put("delete", deleteActionPerformer); // or false
    map.put(DefaultEditorKit.copyAction, copyActionPerformer);
    map.put(DefaultEditorKit.cutAction, cutActionPerformer); 

    /*
    // Popup menu from the keyboard
    map.put ("org.openide.actions.PopupAction",
            new AbstractAction() {
        public void actionPerformed(ActionEvent evt) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    showKeyboardPopup();
                }
            });
        }
    });

    keys.put(KeyStroke.getKeyStroke("control C"), DefaultEditorKit.copyAction);
    keys.put(KeyStroke.getKeyStroke("control X"), DefaultEditorKit.cutAction);
    keys.put(KeyStroke.getKeyStroke("control V"), DefaultEditorKit.pasteAction);
     */
    keys.put(KeyStroke.getKeyStroke("DELETE"), "delete");
}