当前位置: 首页>>代码示例>>Java>>正文


Java InputMap.put方法代码示例

本文整理汇总了Java中javax.swing.InputMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java InputMap.put方法的具体用法?Java InputMap.put怎么用?Java InputMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.InputMap的用法示例。


在下文中一共展示了InputMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exchangeCommands

import javax.swing.InputMap; //导入方法依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AddModulePanel.java

示例2: registerAction

import javax.swing.InputMap; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SearchUtils.java

示例3: init

import javax.swing.InputMap; //导入方法依赖的package包/类
@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");
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:23,代码来源:ObsidianAnimator.java

示例4: initActions

import javax.swing.InputMap; //导入方法依赖的package包/类
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 ) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CategoryList.java

示例5: SpiNNaker_InterfaceFactory

import javax.swing.InputMap; //导入方法依赖的package包/类
/** Creates new form SpiNNaker_InterfaceFactory */
    private SpiNNaker_InterfaceFactory() {
        super();
        setModal(true);
        initComponents();
        setName("SpiNNaker hardware interface chooser");

        // 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) {
                doCloseCancel();
            }
        });
//       String lastSelected = null;
//       AbstractButton defaultButton=null;
//        if ((lastSelected = prefs.get(LAST_SELECTED, null)) != null) {
//            if (lastSelected.equals("doChooseSerial")) {
//                defaultButton=okSerPortButton;
//            } else if (lastSelected.equals("doChooseSocket")) {
//                defaultButton=okSocketButton;
//            } else if (lastSelected.equals("doCloseCancel")) {
//                defaultButton=cancelButton;
//            }
//        }
//        
//
//        getRootPane().registerKeyboardAction(new ButtonClickAction(preferrerdButton), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), JComponent.WHEN_IN_FOCUSED_WINDOW);
        hostTF.setText(prefs.get("SpiNNaker_InterfaceFactory.HOST", HOST));
        portTF.setText(prefs.get("SpiNNaker_InterfaceFactory.UDP_PORT", Integer.toString(UDP_PORT)));
        focusLast();

    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:39,代码来源:SpiNNaker_InterfaceFactory.java

示例6: uninstallKeyBindings

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Stops intercepting certain keystrokes from the text component.
 *
 * @see #installKeyBindings()
 */
private void uninstallKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("PopupWindow: Removing keybindings");
	}
	if (!keyBindingsInstalled) {
		return;
	}

	JTextComponent comp = ac.getTextComponent();
	InputMap im = comp.getInputMap();
	ActionMap am = comp.getActionMap();

	putBackAction(im, am, KeyEvent.VK_ESCAPE, oldEscape);
	putBackAction(im, am, KeyEvent.VK_UP, oldUp);
	putBackAction(im, am, KeyEvent.VK_DOWN, oldDown);
	putBackAction(im, am, KeyEvent.VK_LEFT, oldLeft);
	putBackAction(im, am, KeyEvent.VK_RIGHT, oldRight);
	putBackAction(im, am, KeyEvent.VK_ENTER, oldEnter);
	putBackAction(im, am, KeyEvent.VK_TAB, oldTab);
	putBackAction(im, am, KeyEvent.VK_HOME, oldHome);
	putBackAction(im, am, KeyEvent.VK_END, oldEnd);
	putBackAction(im, am, KeyEvent.VK_PAGE_UP, oldPageUp);
	putBackAction(im, am, KeyEvent.VK_PAGE_DOWN, oldPageDown);

	// Ctrl+C
	KeyStroke ks = getCopyKeyStroke();
	am.put(im.get(ks), oldCtrlC.action); // Original action
	im.put(ks, oldCtrlC.key); // Original key

	comp.removeCaretListener(this);

	keyBindingsInstalled = false;

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:41,代码来源:AutoCompletePopupWindow.java

示例7: EuropeButton

import javax.swing.InputMap; //导入方法依赖的package包/类
public EuropeButton(String text, int keyEvent, String command,
                    ActionListener listener) {
    setOpaque(true);
    setText(text);
    setActionCommand(command);
    addActionListener(listener);
    InputMap closeInputMap = new ComponentInputMap(this);
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, false),
                      "pressed");
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, true),
                      "released");
    SwingUtilities.replaceUIInputMap(this,
                                     JComponent.WHEN_IN_FOCUSED_WINDOW,
                                     closeInputMap);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:16,代码来源:EuropePanel.java

示例8: configureActionMaps

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Installs the keyListener in the textArea and editorPane for handling the enter keystroke and
 * updating the modified state.
 */
protected void configureActionMaps() {
  InputMap editorInputMap = editorPane.getInputMap();
  InputMap textInputMap = textArea.getInputMap();

  // Adds handling for the escape key to cancel editing
  editorInputMap.put(escapeKeystroke, cancelEditingAction);
  textInputMap.put(escapeKeystroke, cancelEditingAction);

  // Adds handling for shift-enter and redirects enter to stop editing
  if (graphComponent.isEnterStopsCellEditing()) {
    editorInputMap.put(shiftEnterKeystroke, editorEnterActionMapKey);
    textInputMap.put(shiftEnterKeystroke, textEnterActionMapKey);

    editorInputMap.put(enterKeystroke, SUBMIT_TEXT);
    textInputMap.put(enterKeystroke, SUBMIT_TEXT);
  } else {
    editorInputMap.put(enterKeystroke, editorEnterActionMapKey);
    textInputMap.put(enterKeystroke, textEnterActionMapKey);

    if (isShiftEnterSubmitsText()) {
      editorInputMap.put(shiftEnterKeystroke, SUBMIT_TEXT);
      textInputMap.put(shiftEnterKeystroke, SUBMIT_TEXT);
    } else {
      editorInputMap.remove(shiftEnterKeystroke);
      textInputMap.remove(shiftEnterKeystroke);
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:33,代码来源:mxCellEditor.java

示例9: TextTool

import javax.swing.InputMap; //导入方法依赖的package包/类
public TextTool(DrawingAttributeSet attrs) {
	this.attrs = attrs;
	curText = null;
	isTextNew = false;
	field = new EditableLabelField();

	fieldListener = new FieldListener();
	InputMap fieldInput = field.getInputMap();
	fieldInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "commit");
	fieldInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
	ActionMap fieldAction = field.getActionMap();
	fieldAction.put("commit", fieldListener);
	fieldAction.put("cancel", new CancelListener());
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:TextTool.java

示例10: installKeyBindings

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
 * Adds key bindings to this popup.
 */
private void installKeyBindings() {

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

	KeyStroke escapeKS = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	im.put(escapeKS, "onEscape");
	am.put("onEscape", new EscapeAction());
	list.getInputMap().remove(escapeKS);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:15,代码来源:ClipboardHistoryPopup.java

示例11: registerAction

import javax.swing.InputMap; //导入方法依赖的package包/类
public KeyStroke registerAction(String actionKey, Action action, ActionMap actionMap, InputMap inputMap) {
    if (!FILTER_ACTION_KEY.equals(actionKey)) return null;
    
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK);
    actionMap.put(actionKey, action);
    inputMap.put(ks, actionKey);

    return ks;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:FilterUtils.java

示例12: ExpPanel

import javax.swing.InputMap; //导入方法依赖的package包/类
public ExpPanel() {
    manager = new ExplorerManager();
    ActionMap map = getActionMap();
    map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager));
    map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager));
    map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager));
    map.put("delete", ExplorerUtils.actionDelete(manager, true));
    lookup = ExplorerUtils.createLookup(manager, map);
    InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    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");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PhadhailViews.java

示例13: eDVS128_InterfaceFactory

import javax.swing.InputMap; //导入方法依赖的package包/类
/**
     * Creates new form eDVS128_InterfaceFactory
     */
    private eDVS128_InterfaceFactory() {
        super();
        setModal(true);
        initComponents();
        setName("eDVS hardware interface chooser");

        // 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() {

            public void actionPerformed(ActionEvent e) {
                doCloseCancel();
            }
        });
//       String lastSelected = null;
//       AbstractButton defaultButton=null;
//        if ((lastSelected = prefs.get(LAST_SELECTED, null)) != null) {
//            if (lastSelected.equals("doChooseSerial")) {
//                defaultButton=okSerPortButton;
//            } else if (lastSelected.equals("doChooseSocket")) {
//                defaultButton=okSocketButton;
//            } else if (lastSelected.equals("doCloseCancel")) {
//                defaultButton=cancelButton;
//            }
//        }
//        
//
//        getRootPane().registerKeyboardAction(new ButtonClickAction(preferrerdButton), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), JComponent.WHEN_IN_FOCUSED_WINDOW);

        Thread T = new InitializePortListThread();
        T.start();
        focusLast();

    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:41,代码来源:eDVS128_InterfaceFactory.java

示例14: setupKeymap

import javax.swing.InputMap; //导入方法依赖的package包/类
private void setupKeymap(Set<Action> actions) {
JComponent comp = term.getScreen();

ActionMap actionMap = comp.getActionMap();
ActionMap newActionMap = new ActionMap();
newActionMap.setParent(actionMap);

printActionMap(actionMap);

InputMap inputMap = comp.getInputMap();
InputMap newInputMap = new InputMap();
newInputMap.setParent(inputMap);

Set<KeyStroke> passKeystrokes = new HashSet<KeyStroke>();

for (Action a : actions) {
    String name = (String) a.getValue(Action.NAME);
           KeyStroke accelerator = (KeyStroke) a.getValue(Action.ACCELERATOR_KEY);
    System.out.printf("Registering %s for %s\n", accelerator, name);
    if (accelerator == null)
	continue;
    newInputMap.put(accelerator, name);
    newActionMap.put(name, a);
    passKeystrokes.add(accelerator);
}

comp.setActionMap(newActionMap);
comp.setInputMap(JComponent.WHEN_FOCUSED, newInputMap);

       term.setKeyStrokeSet((HashSet) passKeystrokes);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Terminal.java

示例15: addToActionMap

import javax.swing.InputMap; //导入方法依赖的package包/类
public static void addToActionMap(JComponent component) {
	ActionMap actionMap = component.getActionMap();
	actionMap.put(TransferHandler.getCutAction().getValue(Action.NAME), TransferHandler.getCutAction());
	actionMap.put(TransferHandler.getCopyAction().getValue(Action.NAME), TransferHandler.getCopyAction());
	actionMap.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction());
	actionMap.put(DeleteOperatorAction.getActionName(), new DeleteOperatorAction());

	// only required if you have not set the menu accelerators
	InputMap inputMap = component.getInputMap();
	inputMap.put(KeyStroke.getKeyStroke("ctrl X"), TransferHandler.getCutAction().getValue(Action.NAME));
	inputMap.put(KeyStroke.getKeyStroke("ctrl C"), TransferHandler.getCopyAction().getValue(Action.NAME));
	inputMap.put(KeyStroke.getKeyStroke("ctrl V"), TransferHandler.getPasteAction().getValue(Action.NAME));
	inputMap.put(KeyStroke.getKeyStroke("del"), DeleteOperatorAction.getActionName());
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:OperatorTransferHandler.java


注:本文中的javax.swing.InputMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。