Java Code Examples for javax.swing.AbstractAction#actionPerformed()
The following examples show how to use
javax.swing.AbstractAction#actionPerformed() .
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: KeyboardPopupSwitcher.java From netbeans with Apache License 2.0 | 6 votes |
/** * Prevents showing a popup if a user releases the <code>releaseKey</code> * in time specified by <code>invokerTimer</code> (which is 200ms by * default). */ private static void processInterruption(KeyEvent kev) { int keyCode = kev.getKeyCode(); if (keyCode == releaseKey && kev.getID() == KeyEvent.KEY_RELEASED) { // if an user releases Ctrl-Tab before the time to show // popup expires, don't show the popup at all and switch to // the last used document immediately cleanupInterrupter(); hits = 0; AbstractAction rva = new ThreadsHistoryAction(); rva.actionPerformed(new ActionEvent(kev.getSource(), ActionEvent.ACTION_PERFORMED, "immediately", kev.getModifiers())); // NOI18N kev.consume(); // #88931: Need to react to KEY_PRESSED, not KEY_RELEASED, to not miss the hit } else if (keyCode == triggerKey && kev.getModifiers() == InputEvent.CTRL_MASK && kev.getID() == KeyEvent.KEY_PRESSED) { // count number of trigger key hits before popup is shown hits++; kev.consume(); cleanupInterrupter(); instance = new KeyboardPopupSwitcher(hits + 1, true); instance.showPopup(); } }
Example 2
Source File: ActionMultiple.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * @param e Event. * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { for (AbstractAction action : actions) { action.actionPerformed(e); } }
Example 3
Source File: TransientActionTest.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@Test public void testProxyDelegatesAllCalls() throws Exception { String[] actionCommand = new String[1]; AbstractAction delegate = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { actionCommand[0] = e.getActionCommand(); } }; delegate.setEnabled(false); TransientAction transientAction = new TransientAction(delegate, "Test/MyAction.instance"); // Enables state assertEquals(false, delegate.isEnabled()); assertEquals(false, transientAction.isEnabled()); transientAction.setEnabled(true); assertEquals(true, delegate.isEnabled()); assertEquals(true, transientAction.isEnabled()); // Property values assertEquals(null, delegate.getValue("XXX")); assertEquals(null, transientAction.getValue("XXX")); transientAction.putValue("XXX", 3456); assertEquals(3456, delegate.getValue("XXX")); assertEquals(3456, transientAction.getValue("XXX")); // Property changes String[] name = new String[1]; transientAction.addPropertyChangeListener(evt -> { name[0] = evt.getPropertyName(); }); assertEquals(null, name[0]); transientAction.putValue("XXX", 9954); assertEquals("XXX", name[0]); delegate.putValue("YYY", 9954); assertEquals("YYY", name[0]); // Action assertEquals(null, actionCommand[0]); delegate.actionPerformed(new ActionEvent(this, 0, "cmd1")); assertEquals("cmd1", actionCommand[0]); transientAction.actionPerformed(new ActionEvent(this, 1, "cmd2")); assertEquals("cmd2", actionCommand[0]); }