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


Java InputMap类代码示例

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


InputMap类属于javax.swing包,在下文中一共展示了InputMap类的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: removeDefaultCutCopyPaste

import javax.swing.InputMap; //导入依赖的package包/类
private void removeDefaultCutCopyPaste(InputMap map) {
    putActionDelegate(map, KeyStroke.getKeyStroke("control C")); // NOI18N
    map.put(KeyStroke.getKeyStroke("control V"), "none"); // NOI18N
    map.put(KeyStroke.getKeyStroke("control X"), "none"); // NOI18N
    putActionDelegate(map, KeyStroke.getKeyStroke("COPY")); // NOI18N
    map.put(KeyStroke.getKeyStroke("PASTE"), "none"); // NOI18N
    map.put(KeyStroke.getKeyStroke("CUT"), "none"); // NOI18N

    if (Utilities.isMac()) {
        putActionDelegate(map, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK)); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.META_MASK), "none"); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK), "none"); // NOI18N
    } else {
        putActionDelegate(map, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK), "none"); // NOI18N
        map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK), "none"); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:OutlineView.java

示例3: populateInputMap

import javax.swing.InputMap; //导入依赖的package包/类
private void populateInputMap(InputMap inputMap) {
    inputMap.put(KeyStroke.getKeyStroke('k'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('K'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('+'), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('='), INCREASE);
    inputMap.put(KeyStroke.getKeyStroke('g'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('G'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('-'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('_'), DECREASE);
    inputMap.put(KeyStroke.getKeyStroke('l'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('L'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('*'), LAST);
    inputMap.put(KeyStroke.getKeyStroke('f'), FIRST);
    inputMap.put(KeyStroke.getKeyStroke('F'), FIRST);
    inputMap.put(KeyStroke.getKeyStroke('/'), FIRST);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Preview.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: installKeyboardActions

import javax.swing.InputMap; //导入依赖的package包/类
@Override
protected void installKeyboardActions() {
    super.installKeyboardActions();

    JTextComponent comp = getComponent();

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();

    InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");

    if (map != null) {
        SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
                                         map);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:XTextAreaPeer.java

示例6: FindInQueryBar

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

示例7: CanvasPane

import javax.swing.InputMap; //导入依赖的package包/类
public CanvasPane(CanvasPaneContents contents) {
	super((Component) contents);
	this.contents = contents;
	this.listener = new Listener();
	this.zoomModel = null;
	// avoid mooving with arrows / pg up down
	InputMap im = this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	im.put(KeyStroke.getKeyStroke("UP"), "none");
	im.put(KeyStroke.getKeyStroke("DOWN"), "none");
	im.put(KeyStroke.getKeyStroke("LEFT"), "none");
	im.put(KeyStroke.getKeyStroke("RIGHT"), "none");
	im.put(KeyStroke.getKeyStroke("PAGE_DOWN"), "none");
	im.put(KeyStroke.getKeyStroke("PAGE_UP"), "none");
	// if (MacCompatibility.mrjVersion >= 0.0) {
	// i don't want the scrollabar you'll move the pane by dragging with poke tool
	setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
	setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	// }

	addComponentListener(listener);
	contents.setCanvasPane(this);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:CanvasPane.java

示例8: clearTableSelectionOnDelete

import javax.swing.InputMap; //导入依赖的package包/类
/**
 * Adds input action map for the tmodel<p>
 * needed as <code>OnKeyPress Edit</code> in autosuggest overriding the
 * basic <code>Delete</code> key press
 *
 * @param table the target tmodel
 */
private static void clearTableSelectionOnDelete(final JTable table) {
    InputMap inputMap = table.getInputMap(WHEN_FOCUSED);
    ActionMap actionMap = table.getActionMap();
    inputMap.put(Keystroke.DELETE, "delete");
    actionMap.put("delete", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelEditing(table);
            ClearSelection(table);
        }

    });
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:23,代码来源:JtableUtils.java

示例9: componentOpened

import javax.swing.InputMap; //导入依赖的package包/类
/** Opened for the first time */
   @Override
   protected void componentOpened() {

Log.getLogger().entering("QueryBuilder", "componentOpened");

       activateActions();
       ActionMap map = getActionMap();
       InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
       installActions(map, keys);
       
       // QueryBuilder does not need to listen to VSE, because it will notify us
       // directly if something changes. The SqlCommandCustomizer needs to listen 
       // to VSE, because that's the only way it is notified of changes to the command 
       // sqlStatement.addPropertyChangeListener(sqlStatementListener) ;
       // vse.addPropertyChangeListener(sqlStatementListener) ;

       // do NOT force a parse here.  It's done in componentShowing().
       // populate( sqlStatement.getCommand()) ;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:QueryBuilder.java

示例10: inserirAtalhos

import javax.swing.InputMap; //导入依赖的package包/类
private void inserirAtalhos() {
    InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);

    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelar");

    getRootPane().getActionMap().put("cancelar", new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            jPanelCards.removeAll();
            dispose();
        }
    });
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:EscolherCard.java

示例11: CheckTreeView

import javax.swing.InputMap; //导入依赖的package包/类
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {
    
    setFocusable( false );
    
    CheckListener l = new CheckListener();
    tree.addMouseListener( l );
    tree.addKeyListener( l );

    CheckRenderer check = new CheckRenderer();
    tree.setCellRenderer( check );
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    tree.setShowsRootHandles(false);
    
    InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
    if( null != input )
        input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );
    
    setBorder( UIManager.getBorder("ScrollPane.border") );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CheckTreeView.java

示例12: BookmarksView

import javax.swing.InputMap; //导入依赖的package包/类
BookmarksView() {
//        getActionMap().put("rename", SystemAction.get(RenameAction.class));
        nodeTree = new BookmarksNodeTree();
        explorerManager = new ExplorerManager();
        explorerManager.setRootContext(nodeTree.rootNode());
        ActionMap actionMap = getActionMap();
        actionMap.put("delete", ExplorerUtils.actionDelete(explorerManager, false)); //NOI18N
        associateLookup(ExplorerUtils.createLookup(explorerManager, actionMap));
        explorerManager.addPropertyChangeListener(this);

        // Ctrl+T will toggle the tree/table view
        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK), "toggle-view"); //NOI18N
        actionMap.put("toggle-view", new AbstractAction() { //NOI18N
            @Override
            public void actionPerformed(ActionEvent e) {
                setTreeViewVisible(!treeViewShowing);
            }
        });
        setIcon(ImageUtilities.loadImage("org/netbeans/modules/editor/bookmarks/resources/bookmark_16.png")); // NOI18N
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BookmarksView.java

示例13: 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

示例14: getInputMap

import javax.swing.InputMap; //导入依赖的package包/类
/**
 * Return JTree's input map.
 */
protected InputMap getInputMap(int condition)
{
	InputMap map = super.getInputMap(condition);

	if (condition == JComponent.WHEN_FOCUSED && map != null)
	{
		map.put(KeyStroke.getKeyStroke("control S"), "save");
		map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs");
		map.put(KeyStroke.getKeyStroke("control N"), "new");
		map.put(KeyStroke.getKeyStroke("control O"), "open");

		map.put(KeyStroke.getKeyStroke("control Z"), "undo");
		map.put(KeyStroke.getKeyStroke("control Y"), "redo");
		map
				.put(KeyStroke.getKeyStroke("control shift V"),
						"selectVertices");
		map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
	}

	return map;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:EditorKeyboardHandler.java

示例15: initDefaultButton

import javax.swing.InputMap; //导入依赖的package包/类
private void initDefaultButton() {
    if(Boolean.getBoolean("bugtracking.suppressActionKeys")) {
        return;
    }
    InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "submit"); // NOI18N
    ActionMap actionMap = getActionMap();
    Action submitAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (submitButton.isEnabled()) {
                submitButtonActionPerformed(null);
            }
        }
    };
    actionMap.put("submit", submitAction); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:IssuePanel.java


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