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


Java JComponent.getInputMap方法代码示例

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


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

示例1: exchangeCommands

import javax.swing.JComponent; //导入方法依赖的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: registerComponent

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
    * Registers a component for tooltip management.
    * <p>
    * This will register key bindings to show and hide the tooltip text
    * only if <code>component</code> has focus bindings. This is done
    * so that components that are not normally focus traversable, such
    * as <code>JLabel</code>, are not made focus traversable as a result
    * of invoking this method.
    *
    * @param component  a <code>JComponent</code> object to add
    * @see JComponent#isFocusTraversable
    */
   protected void registerComponent(JComponent component) {
       component.removeMouseListener(this);
       component.addMouseListener(this);
       component.removeMouseMotionListener(moveBeforeEnterListener);
component.addMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    // register our accessibility keybindings for this component
    // this will apply globally across L&F
    // Post Tip: Ctrl+F1
    // Unpost Tip: Esc and Ctrl+F1
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ToolTipManagerEx.java

示例3: registerAccelerators

import javax.swing.JComponent; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:9,代码来源:PdfJumbler.java

示例4: unregisterComponent

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

示例5: filterInputMap

import javax.swing.JComponent; //导入方法依赖的package包/类
private void filterInputMap(JComponent component, int condition) {
    InputMap imap = component.getInputMap(condition);
    if (imap instanceof ComponentInputMap) {
        imap = new F8FilterComponentInputMap(component, imap);
    } else {
        imap = new F8FilterInputMap(imap);
    }
    component.setInputMap(condition, imap);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OutlineTable.java

示例6: setupKeymap

import javax.swing.JComponent; //导入方法依赖的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

示例7: addToActionMap

import javax.swing.JComponent; //导入方法依赖的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

示例8: addAccelerator

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Adds the accelerator key for a given action to the action and input maps
 * of the simulator frame's content pane.
 * @param action the action to be added
 * @require <tt>frame.getContentPane()</tt> should be initialised
 */
public void addAccelerator(Action action) {
    JComponent contentPane = (JComponent) getFrame().getContentPane();
    ActionMap am = contentPane.getActionMap();
    am.put(action.getValue(Action.NAME), action);
    InputMap im = contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), action.getValue(Action.NAME));
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:Simulator.java

示例9: shouldRegisterBindings

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
    * Returns whether or not bindings should be registered on the given
    * <code>JComponent</code>. This is implemented to return true if the
    * tool tip manager has a binding in any one of the
    * <code>InputMaps</code> registered under the condition
    * <code>WHEN_FOCUSED</code>.
    * <p>
    * This does not use <code>isFocusTraversable</code> as
    * some components may override <code>isFocusTraversable</code> and
    * base the return value on something other than bindings. For example,
    * <code>JButton</code> bases its return value on its enabled state.
    *
    * @param component  the <code>JComponent</code> in question
    */
   private boolean shouldRegisterBindings(JComponent component) {
InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
while (inputMap != null && inputMap.size() == 0) {
    inputMap = inputMap.getParent();
}
return (inputMap != null);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ToolTipManagerEx.java

示例10: zoomMenuCommands

import javax.swing.JComponent; //导入方法依赖的package包/类
/**
 * Adds support for plus and minus menu commands, typically for zooming in
 * and out. This is designed for menu items with key accelerators using
 * KeyEvent.VK_ADD and KeyEvent.VK_SUBTRACT (which are typically on the
 * numerical key pad). It adds support for KeyEvent.VK_MINUS and
 * KeyEvent.VK_PLUS, and KeyEvent.VK_EQUALS for keyboard layouts with the
 * plus sign as secondary key for the equals.
 *
 * @param zoomInAction action to call when the + key and the menu shortcut
 * key are pressed
 * @param zoomOutAction action to call when the - key and the menu shortcut
 * key are pressed
 * @param component component that will receive events and store actions
 */
public static void zoomMenuCommands(Action zoomInAction, Action zoomOutAction, JComponent component) {
    InputMap inputMap = component.getInputMap();
    ActionMap actionMap = component.getActionMap();
    zoomMenuCommands(inputMap, actionMap, zoomInAction, zoomOutAction);
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:20,代码来源:GUIUtil.java


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