javax.swing.InputMap Java Examples
The following examples show how to use
javax.swing.InputMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToolTipManagerEx.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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 } } }
Example #2
Source File: FlatComboBoxUI.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override protected void configureEditor() { super.configureEditor(); // explicitly make non-opaque if( editor instanceof JComponent ) ((JComponent)editor).setOpaque( false ); editor.applyComponentOrientation( comboBox.getComponentOrientation() ); updateEditorColors(); // macOS if( SystemInfo.IS_MAC && editor instanceof JTextComponent ) { // delegate actions from editor text field to combobox, which is necessary // because text field on macOS already handle those keys InputMap inputMap = ((JTextComponent)editor).getInputMap(); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "UP" ) ); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "KP_UP" ) ); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "DOWN" ) ); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "KP_DOWN" ) ); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "HOME" ) ); new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "END" ) ); } }
Example #3
Source File: SearchUtils.java From visualvm with GNU General Public License v2.0 | 6 votes |
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, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); } 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; }
Example #4
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 6 votes |
private WidgetAction createActionMapAction(Page page) { InputMap inputMap = new InputMap(); ActionMap actionMap = new ActionMap(); Action[] actions = page.getActions(true); for (Action action : actions) { KeyStroke keyStroke = (KeyStroke) action.getValue(javax.swing.Action.ACCELERATOR_KEY); if (keyStroke != null) { inputMap.put(keyStroke, action.toString()); actionMap.put(action.toString(), action); } } if (actionMap.size() < 1) { return null; } /* Not sure if it is the right thing to create a new action map * should I be adding it? */ return new MyActionMapAction(inputMap, actionMap); //return ActionFactory.createActionMapAction(inputMap, actionMap); }
Example #5
Source File: CGraphSearchField.java From binnavi with Apache License 2.0 | 6 votes |
/** * Registers all hotkeys processed by the graph search field. */ private void registerHotkeys() { final ActionMap actionMap = ((JTextField) getEditor().getEditorComponent()).getActionMap(); final InputMap imap = ((JTextField) getEditor().getEditorComponent()).getInputMap(); setActionMap(actionMap); setInputMap(JComponent.WHEN_FOCUSED, imap); imap.put(HotKeys.GRAPH_SEARCH_NEXT_KEY.getKeyStroke(), "NEXT"); imap.put(HotKeys.GRAPH_SEARCH_NEXT_ZOOM_KEY.getKeyStroke(), "NEXT_ZOOM"); imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_KEY.getKeyStroke(), "PREVIOUS"); imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_ZOOM_KEY.getKeyStroke(), "PREVIOUS_ZOOM"); actionMap.put("NEXT", CActionProxy.proxy(new CActionHotKey("NEXT"))); actionMap.put("NEXT_ZOOM", CActionProxy.proxy(new CActionHotKey("NEXT_ZOOM"))); actionMap.put("PREVIOUS", CActionProxy.proxy(new CActionHotKey("PREVIOUS"))); actionMap.put("PREVIOUS_ZOOM", CActionProxy.proxy(new CActionHotKey("PREVIOUS_ZOOM"))); }
Example #6
Source File: UIDefaultsDump.java From FlatLaf with Apache License 2.0 | 6 votes |
private void dumpInputMap( PrintWriter out, InputMap inputMap, String indent ) { if( indent == null ) indent = " "; out.printf( "%d %s", inputMap.size(), dumpClass( inputMap ) ); KeyStroke[] keys = inputMap.keys(); if( keys != null ) { Arrays.sort( keys, (keyStroke1, keyStroke2) -> { return String.valueOf( keyStroke1 ).compareTo( String.valueOf( keyStroke2 ) ); } ); for( KeyStroke keyStroke : keys ) { Object value = inputMap.get( keyStroke ); String strKeyStroke = keyStroke.toString().replace( "pressed ", "" ); out.printf( "%n%s%-20s %s", indent, strKeyStroke, value ); } } InputMap parent = inputMap.getParent(); if( parent != null ) dumpInputMap( out, parent, indent + " " ); }
Example #7
Source File: CompareResultImages.java From diirt with MIT License | 6 votes |
/** * Creates new form CompareResultImages */ public CompareResultImages() { initComponents(); toReviewList.setModel(new DefaultListModel()); fillList(); setSize(800, 600); setExtendedState(getExtendedState() | MAXIMIZED_BOTH); actualImage.setStretch(false); referenceImage.setStretch(false); acceptAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control D")); InputMap keyMap = new ComponentInputMap(acceptButton); keyMap.put(KeyStroke.getKeyStroke("control D"), "accept"); ActionMap actionMap = new ActionMapUIResource(); actionMap.put("accept", acceptAction); SwingUtilities.replaceUIActionMap(acceptButton, actionMap); SwingUtilities.replaceUIInputMap(acceptButton, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap); }
Example #8
Source File: CheckTreeView.java From netbeans with Apache License 2.0 | 6 votes |
/** 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") ); }
Example #9
Source File: CheckTreeView.java From netbeans with Apache License 2.0 | 6 votes |
/** 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") ); }
Example #10
Source File: KeyboardHandler.java From tn5250j with GNU General Public License v2.0 | 6 votes |
protected boolean emulatorAction(KeyStroke ks, KeyEvent e){ if (sessionGui == null) return false; InputMap map = getInputMap(); ActionMap am = getActionMap(); if(map != null && am != null && sessionGui.isEnabled()) { Object binding = map.get(ks); Action action = (binding == null) ? null : am.get(binding); if (action != null) { return true; } } return false; }
Example #11
Source File: XTextAreaPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #12
Source File: PopupManager.java From netbeans with Apache License 2.0 | 6 votes |
private void consumeIfKeyPressInActionMap(KeyEvent e) { // get popup's registered keyboard actions ActionMap am = popup.getActionMap(); InputMap im = popup.getInputMap(); // check whether popup registers keystroke // If we consumed key pressed, we need to consume other key events as well: KeyStroke ks = KeyStroke.getKeyStrokeForEvent( new KeyEvent((Component) e.getSource(), KeyEvent.KEY_PRESSED, e.getWhen(), e.getModifiers(), KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()), e.getKeyChar(), e.getKeyLocation()) ); Object obj = im.get(ks); if (shouldPopupReceiveForwardedKeyboardAction(obj)) { // if yes, if there is a popup's action, consume key event Action action = am.get(obj); if (action != null && action.isEnabled()) { // actionPerformed on key press only. e.consume(); } } }
Example #13
Source File: OutlineView.java From netbeans with Apache License 2.0 | 6 votes |
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 } }
Example #14
Source File: SwingSet2.java From beautyeye with Apache License 2.0 | 6 votes |
/** * Creates the popup menu. * * @return the j popup menu */ public JPopupMenu createPopupMenu() { JPopupMenu popup = new JPopupMenu("JPopupMenu demo"); createPopupMenuItem(popup, "LafMenu.java_label", "LafMenu.java_mnemonic", "LafMenu.java_accessible_description", metal); createPopupMenuItem(popup, "LafMenu.windows_label", "LafMenu.windows_mnemonic", "LafMenu.windows_accessible_description", windows); createPopupMenuItem(popup, "LafMenu.gtk_label", "LafMenu.gtk_mnemonic", "LafMenu.gtk_accessible_description", gtk); // register key binding to activate popup menu InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.SHIFT_MASK), "postMenuAction"); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), "postMenuAction"); getActionMap().put("postMenuAction", new ActivatePopupMenuAction(this, popup)); return popup; }
Example #15
Source File: JCloseableTabbedPane.java From wpcleaner with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param tabPlacement the placement for the tabs relative to the content * @param tabLayoutPolicy the policy for laying out tabs when all tabs will not fit on one run */ public JCloseableTabbedPane(int tabPlacement, int tabLayoutPolicy) { super(tabPlacement, tabLayoutPolicy); addKeyListener(this); ActionMap actionMap = getActionMap(); InputMap inputMap = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK); inputMap.put(keyStroke, "close-current-tab"); actionMap.put("close-current-tab", new AbstractAction() { /** Serialization */ private static final long serialVersionUID = -1886432591524366546L; /** * @param e Event. * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { remove(getSelectedIndex()); } }); }
Example #16
Source File: XTextAreaPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #17
Source File: XTextFieldPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #18
Source File: XTextAreaPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #19
Source File: SearchUtils.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example #20
Source File: Preview.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example #21
Source File: frmReleaseNote.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
/** * Manage low level key strokes ESCAPE : Close the window * * @return */ protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE"); @SuppressWarnings("serial") Action actionListener = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(strokeEscape, "ESCAPE"); rootPane.getActionMap().put("ESCAPE", actionListener); return rootPane; }
Example #22
Source File: CAbstractTreeTable.java From binnavi with Apache License 2.0 | 6 votes |
/** * Creates a new abstract tree table object. * * @param projectTree The project tree shown in the main window. * @param model The raw model that is responsible for the table layout. * @param helpInfo Provides context-sensitive information for the table. */ public CAbstractTreeTable(final JTree projectTree, final CAbstractTreeTableModel<T> model, final IHelpInformation helpInfo) { super(model, helpInfo); treeTableModel = Preconditions.checkNotNull(model, "IE01939: Model argument can't be null"); tree = Preconditions.checkNotNull(projectTree, "IE02343: Project tree argument can not be null"); addMouseListener(mouseListener); setDefaultRenderer(String.class, new CProjectTreeTableRenderer()); final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED); windowImap.put(HotKeys.SEARCH_HK.getKeyStroke(), "SEARCH"); getActionMap().put("SEARCH", CActionProxy.proxy(new SearchAction())); windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE"); getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction())); updateUI(); }
Example #23
Source File: FlatLFCustoms.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Object createValue(UIDefaults table) { // get base input map from look and feel defaults (resolves lazy base input map) InputMap inputMap = (InputMap) UIManager.getLookAndFeelDefaults().get(baseKey); // modify input map (replace or remove) for (int i = 0; i < bindings.length; i += 2) { KeyStroke keyStroke = KeyStroke.getKeyStroke((String) bindings[i]); if (bindings[i + 1] != null) { inputMap.put(keyStroke, bindings[i + 1]); } else { inputMap.remove(keyStroke); } } return inputMap; }
Example #24
Source File: StubsController.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
/** * Bind a few keyboard events to actions among assemblies. */ private void bindKeys () { final InputMap inputMap = stubsPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); final ActionMap actionMap = stubsPane.getActionMap(); inputMap.put(KeyStroke.getKeyStroke("PAGE_UP"), "PageUpAction"); actionMap.put("PageUpAction", new PageUpAction()); inputMap.put(KeyStroke.getKeyStroke("PAGE_DOWN"), "PageDownAction"); actionMap.put("PageDownAction", new PageDownAction()); inputMap.put(KeyStroke.getKeyStroke("control HOME"), "CtrlHomeAction"); actionMap.put("CtrlHomeAction", new CtrlHomeAction()); inputMap.put(KeyStroke.getKeyStroke("control END"), "CtrlEndAction"); actionMap.put("CtrlEndAction", new CtrlEndAction()); }
Example #25
Source File: QueryBuilder.java From netbeans with Apache License 2.0 | 6 votes |
/** 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()) ; }
Example #26
Source File: XTextFieldPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #27
Source File: VisualVMActionsSupportProvider.java From visualvm with GNU General Public License v2.0 | 6 votes |
public KeyStroke registerAction(String actionKey, Action action, ActionMap actionMap, InputMap inputMap) { KeyStroke ks = null; if (FilterUtils.FILTER_ACTION_KEY.equals(actionKey)) { ks = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); } else if (SearchUtils.FIND_ACTION_KEY.equals(actionKey)) { ks = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); } else if (SearchUtils.FIND_NEXT_ACTION_KEY.equals(actionKey)) { ks = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0); } else if (SearchUtils.FIND_PREV_ACTION_KEY.equals(actionKey)) { ks = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_MASK); } else if (SearchUtils.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; }
Example #28
Source File: AutoHidingMenuBar.java From netbeans with Apache License 2.0 | 6 votes |
private void populateMenuOpenKeyboardShortcuts(JComponent component) { /* In the future, it would be nice to include the shortcut from o.n.modules.quicksearch.QuickSearchAction/QuickSearchComboBar here. That shortcut isn't set via a regular InputMap, however, so a new cross-module API (maybe a client property that could be set on QuickSearchComboBar) would be needed to let QuickSearchComboBar tell AutoHidingMenuBar about its shortcut. */ InputMap im = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (im != null) { KeyStroke keyStrokes[] = im.allKeys(); if (keyStrokes != null) { for (KeyStroke keyStroke : keyStrokes) { menuOpenKeyboardShortcuts.put(keyStroke, "OpenMenu"); // Value doesn't matter, just use some non-null string. } } } // Don't descend into the actual menus. if (!(component instanceof JMenu)) { for (Component childComponent : component.getComponents()) { if (childComponent instanceof JComponent) populateMenuOpenKeyboardShortcuts((JComponent) childComponent); } } }
Example #29
Source File: NbEditorToolBar.java From netbeans with Apache License 2.0 | 6 votes |
private void installNoOpActionMappings(){ InputMap im = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // cut KeyStroke[] keys = findEditorKeys(DefaultEditorKit.cutAction, KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); for (int i = 0; i < keys.length; i++) { im.put(keys[i], NOOP_ACTION_KEY); } // copy keys = findEditorKeys(DefaultEditorKit.copyAction, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); for (int i = 0; i < keys.length; i++) { im.put(keys[i], NOOP_ACTION_KEY); } // delete keys = findEditorKeys(DefaultEditorKit.deleteNextCharAction, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); //NOI18N for (int i = 0; i < keys.length; i++) { im.put(keys[i], NOOP_ACTION_KEY); } // paste keys = findEditorKeys(DefaultEditorKit.pasteAction, KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK)); for (int i = 0; i < keys.length; i++) { im.put(keys[i], NOOP_ACTION_KEY); } getActionMap().put(NOOP_ACTION_KEY, NOOP_ACTION); }
Example #30
Source File: JavaElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 6 votes |
private String getKeyStrokeFor(String action) { JSONArray r = new JSONArray(); if (component instanceof JComponent) { InputMap inputMap = ((JComponent) component).getInputMap(); KeyStroke[] allKeys = inputMap.allKeys(); for (KeyStroke ks : allKeys) { if (action.equals(inputMap.get(ks))) { r.put(ks.toString()); } } } if (r.length() > 0) { return r.toString(); } return null; }