Java Code Examples for javax.swing.JComponent#getActionMap()
The following examples show how to use
javax.swing.JComponent#getActionMap() .
These examples are extracted from open source projects.
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 Project: jclic File: Actions.java License: GNU General Public License v2.0 | 6 votes |
public static void mapAction(JComponent jc, Map<String, Object[]> actionKeys, Action act, String key) { if (actionKeys == null) { actionKeys = getActionKeys(jc); } if (jc != null && actionKeys != null) { ActionMap am = jc.getActionMap(); Object[] keys = actionKeys.get(key); boolean replaced = false; if (keys != null) { for (Object k : keys) { am.put(k, act); if (k.equals(key)) { replaced = true; } } } if (!replaced) { am.put(key, act); } } }
Example 2
Source Project: netbeans File: ToolTipManagerEx.java License: 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 3
Source Project: jclic File: Actions.java License: GNU General Public License v2.0 | 6 votes |
/** * Collects the keys of all the actions linked to a specific * {@link javax.swing.JComponent} and groups them in arrays by action names. * * @param jc The JComponent with the actions linked to. * @return A HashMap formed by pairs of action names (key) and arrays of action * keys (value). Usually each action name has only one action key * associated to it, and the value of the pair is an object array with * only one string, but this is not an imperative: several actions can * be associated to a single name. */ public static Map<String, Object[]> getActionKeys(JComponent jc) { Map<String, Object[]> result = new HashMap<String, Object[]>(); ActionMap am = jc.getActionMap(); for (Object amk : am.allKeys()) { Action act = am.get(amk); Object o = act.getValue(Action.NAME); if (o == null) o = ""; String name = o.toString(); Object[] keys = result.get(name); if (keys == null) keys = new Object[] { amk }; else { Object[] k2 = new Object[keys.length + 1]; int j; for (j = 0; j < keys.length; j++) k2[j] = keys[j]; k2[j] = amk; keys = k2; } result.put(name, keys); } return result; }
Example 4
Source Project: jdk8u-dev-jdk File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 5
Source Project: TencentKona-8 File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 6
Source Project: openjdk-8 File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 7
Source Project: openjdk-jdk8u File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 8
Source Project: netbeans File: ToolTipManagerEx.java License: Apache License 2.0 | 5 votes |
/** * Removes a component from tooltip control. * * @param component a <code>JComponent</code> object to remove */ protected void unregisterComponent(JComponent component) { component.removeMouseListener(this); component.removeMouseMotionListener(moveBeforeEnterListener); if (shouldRegisterBindings(component)) { InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED); ActionMap actionMap = component.getActionMap(); if (inputMap != null && actionMap != null) { //XXX remove } } }
Example 9
Source Project: netbeans-mmd-plugin File: MMDGraphEditor.java License: Apache License 2.0 | 5 votes |
private void registerCustomCCPActions(@Nonnull final JComponent component) { final ActionMap actionMap = component.getActionMap(); actionMap.put(DefaultEditorKit.cutAction, this.actionCut); actionMap.put(DefaultEditorKit.copyAction, this.actionCopy); actionMap.put(DefaultEditorKit.pasteAction, this.actionPaste); actionMap.put(FindAction.class.getName(), findAction); }
Example 10
Source Project: openjdk-jdk8u-backup File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 11
Source Project: Bytecoder File: BasicLookAndFeel.java License: Apache License 2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 12
Source Project: openjdk-jdk9 File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 13
Source Project: jdk8u-jdk File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 14
Source Project: pgptool File: JCheckList.java License: GNU General Public License v3.0 | 5 votes |
private void addSpaceActionhandler(JComponent host) { InputMap inputMap = host.getInputMap(); ActionMap actionMap = host.getActionMap(); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0); String key = keyStroke.toString(); inputMap.put(keyStroke, key); actionMap.put(key, invertCheckAction); }
Example 15
Source Project: audiveris File: ScrollView.java License: GNU Affero General Public License v3.0 | 5 votes |
private void bindKeys (JComponent component) { InputMap inputMap; // inputMap = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // inputMap = component.getInputMap(JComponent.WHEN_FOCUSED); // Default inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = component.getActionMap(); inputMap.put(KeyStroke.getKeyStroke("UP"), "UpAction"); actionMap.put("UpAction", new UpAction()); inputMap.put(KeyStroke.getKeyStroke("DOWN"), "DownAction"); actionMap.put("DownAction", new DownAction()); inputMap.put(KeyStroke.getKeyStroke("shift UP"), "ShiftUpAction"); actionMap.put("ShiftUpAction", new ShiftUpAction()); inputMap.put(KeyStroke.getKeyStroke("shift DOWN"), "ShiftDownAction"); actionMap.put("ShiftDownAction", new ShiftDownAction()); inputMap.put(KeyStroke.getKeyStroke("LEFT"), "LeftAction"); actionMap.put("LeftAction", new LeftAction()); inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "RightAction"); actionMap.put("RightAction", new RightAction()); inputMap.put(KeyStroke.getKeyStroke("shift LEFT"), "ShiftLeftAction"); actionMap.put("ShiftLeftAction", new ShiftLeftAction()); inputMap.put(KeyStroke.getKeyStroke("shift RIGHT"), "ShiftRightAction"); actionMap.put("ShiftRightAction", new ShiftRightAction()); }
Example 16
Source Project: jdk8u_jdk File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 17
Source Project: Java8CN File: BasicLookAndFeel.java License: Apache License 2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 18
Source Project: hottub File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 19
Source Project: openjdk-8-source File: BasicLookAndFeel.java License: GNU General Public License v2.0 | 5 votes |
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
Example 20
Source Project: pentaho-reporting File: WelcomePane.java License: GNU Lesser General Public License v2.1 | 3 votes |
private void init( final ReportDesignerContext reportDesignerContext ) { if ( reportDesignerContext == null ) { throw new NullPointerException(); } setTitle( Messages.getString( "WelcomePane.title" ) ); // NON-NLS this.reportDesignerContext = reportDesignerContext; this.newReportAction = new NewReportAction(); this.newReportAction.setReportDesignerContext( reportDesignerContext ); this.closeActionListener = new CloseActionListener(); showOnStartupCheckbox = new JCheckBox( Messages.getString( "WelcomePane.showAtStartup" ), WorkspaceSettings.getInstance().isShowLauncher() ); // NON-NLS showOnStartupCheckbox.addActionListener( new TriggerShowWelcomePaneAction() ); backgroundImage = Toolkit.getDefaultToolkit().createImage( IconLoader.class.getResource( "/org/pentaho/reporting/designer/core/icons/WelcomeBackground.png" ) ); // NON-NLS final WaitingImageObserver obs = new WaitingImageObserver( backgroundImage ); obs.waitImageLoaded(); setResizable( false ); initGUI(); pack(); 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 CloseActionListener() ); // NON-NLS }