本文整理匯總了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);
}
}
}
}
示例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;
}
示例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");
}
示例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 ) );
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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());
}
示例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);
}
示例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;
}
示例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");
}
示例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();
}
示例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);
}
示例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());
}