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