當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。