javax.swing.InputMap#put ( )源码实例Demo

下面列出了javax.swing.InputMap#put ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: binnavi   文件: CAddressSpacesTable.java
/**
 * Creates a new address spaces table.
 * 
 * @param projectTree Project tree of the main window.
 * @param database Database the address space belongs to.
 * @param project The project that contains the address spaces.
 * @param container View container of the project.
 */
public CAddressSpacesTable(final JTree projectTree, final IDatabase database,
    final INaviProject project, final IViewContainer container) {
  super(projectTree, new CAddressSpacesModel(project), new CAddressSpacesTableHelp());

  m_database = Preconditions.checkNotNull(database, "IE02871: database argument can not be null");
  m_project = Preconditions.checkNotNull(project, "IE02872: project argument can not be null");
  m_container =
      Preconditions.checkNotNull(container, "IE02873: container argument can not be null");

  setDefaultRenderer(Object.class, new AddressSpaceLoadedRenderer());

  final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);

  windowImap.put(HotKeys.LOAD_HK.getKeyStroke(), "LOAD");
  getActionMap().put("LOAD", CActionProxy.proxy(new LoadAddressSpaceAction()));
}
 
源代码2 项目: binnavi   文件: CAbstractTreeTable.java
/**
 * Creates a new abstract tree table object.
 *
 * @param projectTree The project tree shown in the main window.
 * @param model The raw model that is responsible for the table layout.
 * @param helpInfo Provides context-sensitive information for the table.
 */
public CAbstractTreeTable(final JTree projectTree, final CAbstractTreeTableModel<T> model,
    final IHelpInformation helpInfo) {
  super(model, helpInfo);

  treeTableModel = Preconditions.checkNotNull(model, "IE01939: Model argument can't be null");
  tree =
      Preconditions.checkNotNull(projectTree, "IE02343: Project tree argument can not be null");

  addMouseListener(mouseListener);

  setDefaultRenderer(String.class, new CProjectTreeTableRenderer());

  final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);

  windowImap.put(HotKeys.SEARCH_HK.getKeyStroke(), "SEARCH");
  getActionMap().put("SEARCH", CActionProxy.proxy(new SearchAction()));

  windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE");
  getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction()));

  updateUI();
}
 
源代码3 项目: 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();
        }
    });
}
 
源代码4 项目: FlatLaf   文件: FlatInputMaps.java
@Override
public Object createValue( UIDefaults table ) {
	// get base input map
	InputMap inputMap = (baseInputMap instanceof LazyValue)
		? (InputMap) ((LazyValue)baseInputMap).createValue( table )
		: (InputMap) baseInputMap;

	// modify input map (replace or remove)
	for( int i = 0; i < bindings.length; i += 2 ) {
		KeyStroke keyStroke = KeyStroke.getKeyStroke( (String) bindings[i] );
		if( bindings[i + 1] != null )
			inputMap.put( keyStroke, bindings[i + 1] );
		else
			inputMap.remove( keyStroke );
	}

	return inputMap;
}
 
源代码5 项目: visualvm   文件: 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, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    } 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;
}
 
源代码6 项目: 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);
            }
        }
    }
}
 
源代码7 项目: Course_Generator   文件: frmSearchPoint.java
/**
 * Manage low level key strokes ESCAPE : Close the window
 *
 * @return
 */
protected JRootPane createRootPane() {
	JRootPane rootPane = new JRootPane();
	KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE");

	@SuppressWarnings("serial")
	Action actionListener = new AbstractAction() {
		public void actionPerformed(ActionEvent actionEvent) {
			setVisible(false);
		}
	};

	InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	inputMap.put(strokeEscape, "ESCAPE");
	rootPane.getActionMap().put("ESCAPE", actionListener);

	return rootPane;
}
 
源代码8 项目: rapidminer-studio   文件: GlobalSearchPanel.java
/**
 * Initializes the Global Search result visualization. Has no effect if it already is visualized.
 */
public void initializeSearchResultVisualization() {
	synchronized (SINGLETON_LOCK) {
		if (resultDialog == null) {
			resultDialog = new GlobalSearchDialog(ApplicationFrame.getApplicationFrame(), controller) {

				@Override
				public Dimension getPreferredSize() {
					// make sure width is same as this panel + width of the i18n label
					int width = PREFERRED_WIDTH + GlobalSearchCategoryPanel.I18N_NAME_WIDTH + 1;
					Dimension prefSize = super.getPreferredSize();
					prefSize.width = width;

					// make sure height does not exceed certain amount
					prefSize.height = Math.min(prefSize.height, MAX_RESULT_DIALOG_HEIGHT);

					return prefSize;
				}
			};
			resultDialog.setFocusableWindowState(false);

			// even though dialog cannot be focused, it should hide when RM Studio is minimized
			ApplicationFrame.getApplicationFrame().addWindowListener(new WindowAdapter() {

				@Override
				public void windowIconified(WindowEvent e) {
					GlobalSearchPanel.this.hideComponents();
				}
			});

			// also close everything if results are displayed
			InputMap inputMap = resultDialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
			ActionMap actionMap = resultDialog.getRootPane().getActionMap();

			inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CLOSE_FULL_SEARCH_DIALOG);
			addCloseFullSearchDialogAction(actionMap);
		}
	}
}
 
源代码9 项目: freecol   文件: EuropePanel.java
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);
}
 
源代码10 项目: binnavi   文件: CGraphHotkeys.java
/**
 * Register the default hotkeys of a graph view.
 * 
 * @param parent Parent window used for dialogs.
 * @param panel The panel where the view is shown.
 * @param debuggerProvider Provides the debugger used by some hotkeys.
 * @param searchField The search field that is shown in the graph panel.
 * @param addressField The address field that is shown in the graph panel.
 */
public static void registerHotKeys(final JFrame parent, final CGraphPanel panel,
    final IFrontEndDebuggerProvider debuggerProvider, final CGraphSearchField searchField,
    final CGotoAddressField addressField) {
  Preconditions.checkNotNull(parent, "IE01606: Parent argument can not be null");
  Preconditions.checkNotNull(panel, "IE01607: Panel argument can not be null");
  Preconditions.checkNotNull(searchField, "IE01608: Search field argument can not be null");
  Preconditions.checkNotNull(addressField, "IE01609: Address field argument can not be null");

  final InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  final ActionMap actionMap = panel.getActionMap();

  inputMap.put(HotKeys.GRAPH_GOTO_ADDRESS_FIELD_KEY.getKeyStroke(), "GOTO_ADDRESS_FIELD");

  actionMap.put("GOTO_ADDRESS_FIELD", new AbstractAction() {
    /**
     * Used for serialization.
     */
    private static final long serialVersionUID = -8994014581850287793L;

    @Override
    public void actionPerformed(final ActionEvent event) {
      addressField.requestFocusInWindow();
    }
  });

  inputMap.put(HotKeys.GRAPH_SHOW_HOTKEYS_ACCELERATOR_KEY.getKeyStroke(), "SHOW_HOTKEYS");
  actionMap.put("SHOW_HOTKEYS", new CShowHotkeysAction(parent));

  registerSearchKeys(panel.getModel().getGraph().getView(), searchField, inputMap, actionMap);

  registerDebuggerKeys(panel.getModel().getParent(), panel.getModel().getGraph(),
      debuggerProvider, inputMap, actionMap);
}
 
源代码11 项目: Logisim   文件: TableTabCaret.java
TableTabCaret(TableTab table) {
	this.table = table;
	cursorRow = 0;
	cursorCol = 0;
	markRow = 0;
	markCol = 0;
	table.getTruthTable().addTruthTableListener(listener);
	table.addMouseListener(listener);
	table.addMouseMotionListener(listener);
	table.addKeyListener(listener);
	table.addFocusListener(listener);

	InputMap imap = table.getInputMap();
	ActionMap amap = table.getActionMap();
	AbstractAction nullAction = new AbstractAction() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 7932515593155479627L;

		@Override
		public void actionPerformed(ActionEvent e) {
		}
	};
	String nullKey = "null";
	amap.put(nullKey, nullAction);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), nullKey);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), nullKey);
}
 
源代码12 项目: 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
    }
}
 
源代码13 项目: 3Dscript   文件: AnimationAutoCompletion.java
/**
 * Uninstalls this auto-completion from its text component. If it is not
 * installed on any text component, nothing happens.
 *
 * @see #install(JTextComponent)
 */
@Override
public void uninstall() {

	if (textComponent != null) {

		hidePopupWindow(); // Unregisters listeners, actions, etc.

		uninstallTriggerKey();

		// Uninstall the function completion key.
		char start = provider.getParameterListStart();
		if (start != 0) {
			KeyStroke ks = KeyStroke.getKeyStroke(start);
			InputMap im = textComponent.getInputMap();
			im.put(ks, oldParenKey);
			ActionMap am = textComponent.getActionMap();
			am.put(PARAM_COMPLETE_KEY, oldParenAction);
		}

		textComponentListener.removeFrom(textComponent);
		if (parentWindow != null) {
			parentWindowListener.removeFrom(parentWindow);
		}

		if (isAutoActivationEnabled()) {
			autoActivationListener.removeFrom(textComponent);
		}

		UIManager.removePropertyChangeListener(lafListener);

		textComponent = null;
		popupWindowListener.uninstall(popupWindow);
		popupWindow = null;

	}

}
 
源代码14 项目: pcgen   文件: PCGenFrame.java
private static InputMap createInputMap(ActionMap actionMap)
{
	InputMap inputMap = new InputMap();
	for (Object obj : actionMap.keys())
	{
		KeyStroke key = (KeyStroke) actionMap.get(obj).getValue(Action.ACCELERATOR_KEY);
		if (key != null)
		{
			inputMap.put(key, obj);
		}
	}
	return inputMap;
}
 
源代码15 项目: pcgen   文件: StatTableModel.java
public StatTableModel(CharacterFacade character, JTable jtable)
{
	this.character = character;
	this.table = jtable;
	this.stats = character.getDataSet().getStats();
	int min = Integer.MAX_VALUE;
	for (PCStat sf : stats)
	{
		min = Math.min(sf.getSafe(IntegerKey.MIN_VALUE), min);
	}
	editor.setMinValue(min);

	final JTextField field = editor.getTextField();
	InputMap map = field.getInputMap(JComponent.WHEN_FOCUSED);

	map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), MOVEDOWN);
	map.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), MOVEDOWN);
	Action action = new AbstractAction()
	{

		@Override
		public void actionPerformed(ActionEvent e)
		{
			//Logging.log(Logging.WARNING, "Got handleEnter from " + e.getSource());
			int row = table.getEditingRow();
			final int col = table.getEditingColumn();
			table.getCellEditor().stopCellEditing(); // store user input
			final int nextRow = row + 1;
			startEditingNextRow(table, col, nextRow, field);
		}

	};
	field.getActionMap().put(MOVEDOWN, action);
}
 
源代码16 项目: 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);
    }
}
 
源代码17 项目: FlatLaf   文件: FlatComboBoxUI.java
EditorDelegateAction( InputMap inputMap, KeyStroke keyStroke ) {
	this.keyStroke = keyStroke;

	// add to input map
	inputMap.put( keyStroke, this );
}
 
源代码18 项目: triplea   文件: CommentPanel.java
private void setupKeyMap() {
  final InputMap nextMessageKeymap = nextMessage.getInputMap();
  nextMessageKeymap.put(KeyStroke.getKeyStroke('\n'), saveAction);
}
 
源代码19 项目: gate-core   文件: AnnotationEditor.java
private void setShortCuts(InputMap inputMap, String[] keyStrokes,
    String action) {
  for(String aKeyStroke : keyStrokes) {
    inputMap.put(KeyStroke.getKeyStroke(aKeyStroke), action);
  }
}
 
源代码20 项目: binnavi   文件: CMemoryRangeDialog.java
/**
 * Creates a new memory range dialog.
 * 
 * @param owner The parent frame of the dialog.
 */
public CMemoryRangeDialog(final JFrame owner) {
  super(owner, "Enter a memory range", true);

  setLayout(new BorderLayout());

  setSize(400, 170);

  final JLabel startLabel = new JLabel("Start Address (Hex)");

  final JLabel endLabel = new JLabel("Number of Bytes (Hex)");

  m_startField = new JFormattedTextField(new CHexFormatter(8));
  m_endField = new JFormattedTextField(new CHexFormatter(8));

  final JPanel labelPanel = new JPanel(new GridBagLayout());

  final GridBagConstraints constraints = new GridBagConstraints();

  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.weightx = 0.2;
  constraints.insets = new Insets(5, 5, 0, 0);
  constraints.fill = GridBagConstraints.HORIZONTAL;

  labelPanel.add(startLabel, constraints);

  constraints.gridx = 1;
  constraints.gridy = 0;
  constraints.weightx = 1;
  constraints.insets = new Insets(5, 0, 0, 0);
  labelPanel.add(m_startField, constraints);

  constraints.gridx = 0;
  constraints.gridy = 1;
  constraints.weightx = 0.2;
  constraints.insets = new Insets(5, 5, 0, 0);

  labelPanel.add(endLabel, constraints);

  constraints.gridx = 1;
  constraints.gridy = 1;
  constraints.weightx = 1;
  constraints.insets = new Insets(5, 0, 0, 0);
  labelPanel.add(m_endField, constraints);

  final JPanel topPanel = new JPanel(new BorderLayout());

  final JTextArea area =
      new JTextArea(
          "Please enter a memory range to display. \nBe careful. Displaying invalid memory can crash the device.");
  area.setBorder(new EmptyBorder(0, 5, 0, 0));

  area.setEditable(false);

  topPanel.add(area, BorderLayout.NORTH);
  topPanel.add(labelPanel, BorderLayout.CENTER);

  topPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK)));

  final CPanelTwoButtons buttonPanel =
      new CPanelTwoButtons(new InternalListener(), "OK", "Cancel");

  add(topPanel, BorderLayout.NORTH);
  add(buttonPanel, BorderLayout.SOUTH);

  m_startField.requestFocusInWindow();

  final InputMap windowImap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

  windowImap.put(HotKeys.APPLY_HK.getKeyStroke(), "APPLY");
  getRootPane().getActionMap().put("APPLY", CActionProxy.proxy(new ApplyAction()));

  setLocationRelativeTo(null);
}
 
 方法所在类
 同类方法