Java 8 InputMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InputMap class.

This code example shows how to use the following methods:put
				menuItem.setAccelerator(def.getAccelerator());
			} else { 
				//special logic to support accelerator on JButton (issue 86) 
				if (button instanceof JButton) {
					 
					InputMap keyMap = new ComponentInputMap(button);
					keyMap.put(def.getAccelerator(), "action");
 
					ActionMap actionMap = new ActionMapUIResource();
					actionMap.put("action", new AbstractAction() {
						@Override 
						public void actionPerformed(ActionEvent e) {
							 
							ActionEvent evt = new ActionEvent(button, ActionEvent.ACTION_PERFORMED, "action");
							 
							//fire event listeners 
							if (button.getActionListeners() != null) {
								for(ActionListener listener : button.getActionListeners()) {
									listener.actionPerformed(evt);
								} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:put
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;
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setParent
	 * issue warnings that you are not actually overriding the original method 
	 * (since it is package-private). 
	 */ 
	@Override 
	protected InputMap getRTextAreaInputMap() {
		InputMap map = new InputMapUIResource();
		InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME);
		if (shared==null) {
			shared = new RSyntaxTextAreaDefaultInputMap();
			UIManager.put(SHARED_INPUT_MAP_NAME, shared);
		} 
		//KeyStroke[] keys = shared.allKeys(); 
		//for (int i=0; i<keys.length; i++) 
		//	System.err.println(keys[i] + " -> " + shared.get(keys[i])); 
		map.setParent(shared);
		return map;
	} 
 
 
	/** 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
        this.target = target;
    } 
 
    @Override 
    public Object get(KeyStroke keyStroke) {
        return target.get(keyStroke);
    } 
 
    @Override 
    public KeyStroke[] keys() {
        return target.keys();
    } 
 
    @Override 
    public int size() { 
        return target.size();
    } 
 
    @Override 
    public KeyStroke[] allKeys() {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:put
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:put
 
    final JComponent contentPane = (JComponent) getContentPane();
    final InputMap inputMap = contentPane.getInputMap();
    final ActionMap actionMap = contentPane.getActionMap();
 
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS
    actionMap.put("cancel", new IgnoreAction()); // NON-NLS
 
  } 
 
  protected Action getYesAction()
  { 
    return yesAction;
  } 
 
  public boolean isSelectionActive() 
  { 
    return updateList.getSelectedRow() != -1;
  } 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:put
                    cancel(); 
            } 
        }; 
	 
        // Maps the dispose action to the 'Escape' keystroke 
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CUSTOM_DISPOSE_EVENT);
        actionMap.put(CUSTOM_DISPOSE_EVENT, disposeAction);
		 
        // Maps the dispose action to the 'Apple+W' keystroke under Mac OS X 
        if(OsFamily.MAC_OS_X.isCurrent()) 
            inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.META_MASK), CUSTOM_DISPOSE_EVENT);
 
        // Under Windows, Alt+F4 automagically disposes the dialog, nothing to do 
    } 
 
    /** 
     * Method called when the user has canceled through the escape key. 
     * <p> 
     * This method is equivalent to a call to {@link #dispose()}. It's meant to be 
     * overriden by those implementations of <code>FocusDialog</code> that need to run 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:put
    } 
 
    private void init() { 
   		addChangeListener( this );
   		final InputMap imap = getInputMap();
   		imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_LEFT,  0 ), "none" );
   		imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_UP,    0 ), "none" );
   		imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_RIGHT, 0 ), "none" );
   		imap.put( KeyStroke.getKeyStroke( KeyEvent.VK_DOWN,  0 ), "none" );
   	} 
 
    public void setValueNoAction( int n ) {
   		removeChangeListener( this );
   		super.setValue( n );
   		addChangeListener( this );
   	} 
 
    public synchronized void addActionListener( ActionListener l ) {
   		al = AWTEventMulticaster.add( al, l );
   	} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:keys, put, remove
     */ 
    public static void registerComponentAtTooltipManager(JComponent c) {
        InputMap imap = c.getInputMap();
 
        boolean removeKeyStroke = false;
        KeyStroke[] ks = imap.keys();
        if(ks == null || ks.length == 0) {
            imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, 0), "backSlash");   // dummy
            removeKeyStroke = true;
        } 
 
        ToolTipManager.sharedInstance().registerComponent(c);
//      ToolTipManager.sharedInstance().setDismissDelay(99000);     // set showing time to 99 seconds 
 
        if(removeKeyStroke) {
            imap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, 0));
        } 
 
        c.addMouseListener(MOUSE_HANDLER);
    } 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 InputMap Methods: