Java Code Examples for javax.swing.JComponent#getActionMap()
The following examples show how to use
javax.swing.JComponent#getActionMap() .
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: Actions.java From jclic with 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 3
Source File: Actions.java From jclic with 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 4
Source File: BasicLookAndFeel.java From openjdk-jdk8u-backup with 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 File: BasicLookAndFeel.java From openjdk-8-source with 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 File: BasicLookAndFeel.java From hottub with 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 File: BasicLookAndFeel.java From Java8CN with 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 8
Source File: BasicLookAndFeel.java From jdk8u_jdk with 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 9
Source File: ScrollView.java From audiveris with 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 10
Source File: JCheckList.java From pgptool with 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 11
Source File: BasicLookAndFeel.java From jdk8u-jdk with 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 12
Source File: BasicLookAndFeel.java From openjdk-jdk9 with 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 File: BasicLookAndFeel.java From Bytecoder with 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 14
Source File: MMDGraphEditor.java From netbeans-mmd-plugin with 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 15
Source File: ToolTipManagerEx.java From netbeans with 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 16
Source File: BasicLookAndFeel.java From openjdk-jdk8u with 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 File: BasicLookAndFeel.java From openjdk-8 with 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 18
Source File: BasicLookAndFeel.java From TencentKona-8 with 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 File: BasicLookAndFeel.java From jdk8u-dev-jdk with 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 File: WelcomePane.java From pentaho-reporting with 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 }