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,"none"); // NOI18N
    } else {
        putActionDelegate(map,InputEvent.CTRL_DOWN_MASK)); // NOI18N
        map.put(Keystroke.getKeystroke(KeyEvent.VK_X,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,false ),"defaultAction" );
    inputMap.put( Keystroke.getKeystroke( KeyEvent.VK_F10,KeyEvent.SHIFT_DOWN_MASK,"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 ) );
    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,"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,"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,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,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,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,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,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,KeyEvent.VK_ENTER);
    objLactionMap.put(KeyEvent.VK_ENTER,new KeysAction(objPcontrolJFrame,KeysAction.bytS_SHORTCUTS_J_COMBO_Box));
    objLinputMap.put(Keystroke.getKeystroke(KeyEvent.VK_SPACE,KeyEvent.VK_SPACE);
    objLactionMap.put(KeyEvent.VK_SPACE,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,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,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,ACTION_EXPAND);
    imp.put(Keystroke.getKeystroke(KeyEvent.VK_LEFT,ACTION_COLLAPSE);
    imp.put(Keystroke.getKeystroke(KeyEvent.VK_ENTER,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,"collapse" ); //NOI18N
    inputMap.put( Keystroke.getKeystroke( KeyEvent.VK_RIGHT,"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.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,"messageHistory" ); //NOI18N
        actionMap.put("messageHistory",(Action) action); //NOI18N
    }
    action = templatesLabel.getClientProperty("openAction");
    if (action instanceof Action) {
        inputMap.put( Keystroke.getKeystroke( KeyEvent.VK_L,"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,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,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,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,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");
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...