Java Code Examples for java.awt.event.ActionEvent#ACTION_PERFORMED

The following examples show how to use java.awt.event.ActionEvent#ACTION_PERFORMED . 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: Util.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
Example 2
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
Example 3
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
Example 4
Source File: Util.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
Example 5
Source File: PerformanceMonitor.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e)
{
        int row = table.convertRowIndexToModel( table.getEditingRow() );
        fireEditingStopped();

        //  Invoke the Action

        ActionEvent event = new ActionEvent(
                table,
                ActionEvent.ACTION_PERFORMED,
                "" + row);
        action.actionPerformed(event);
}
 
Example 6
Source File: Selector.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Notify listeners that selected values changes
 */
protected void fireActionEvent() {
	if (!firingActionEvent) {
		firingActionEvent = true;
		ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "selectorChanged");

		for (ActionListener listener : listenerList.getListeners(ActionListener.class))
			listener.actionPerformed(event);

		firingActionEvent = false;
	}
}
 
Example 7
Source File: HyperlinkCellRenderer.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent event) {
    if (checkIfPointInsideHyperlink(event.getPoint())) {

        ActionEvent actionEvent = new ActionEvent(new Integer(hitRowIndex),
                ActionEvent.ACTION_PERFORMED,
                "hyperlink");

        HyperlinkCellRenderer.this.fireActionPerformed(actionEvent);

        setCellLinkVisited(table.getValueAt(hitRowIndex, hitColumnIndex),
                hitRowIndex, hitColumnIndex);

    }
}
 
Example 8
Source File: ShortcutAndMenuKeyEventProcessor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean processShortcut(KeyEvent ev) {
    //ignore shortcut keys when the IDE is shutting down
    if (NbLifecycleManager.isExiting()) {
        ev.consume();
        return true;
    }
    
    KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev);
    Window w = SwingUtilities.windowForComponent(ev.getComponent());

    // don't process shortcuts if this is a help frame
    if ((w instanceof JFrame) && ((JFrame)w).getRootPane().getClientProperty("netbeans.helpframe") != null) // NOI18N
        return true;
    
    // don't let action keystrokes to propagate from both
    // modal and nonmodal dialogs, but propagate from separate floating windows,
    // even if they are backed by JDialog
    if ((w instanceof Dialog) &&
        !WindowManagerImpl.isSeparateWindow(w) &&
        !isTransmodalAction(ks)) {
        return false;
    }
    
    // Provide a reasonably useful action event that identifies what was focused
    // when the key was pressed, as well as what keystroke ran the action.
    ActionEvent aev = new ActionEvent(
        ev.getSource(), ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks));
        
    Keymap root = Lookup.getDefault().lookup(Keymap.class);
    Action a = root.getAction (ks);
    if (a != null && a.isEnabled()) {
        ActionManager am = Lookup.getDefault().lookup(ActionManager.class);
        am.invokeAction(a, aev);
        ev.consume();
        return true;
    }
    return false;
}
 
Example 9
Source File: SlideBarActionEvent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SlideBarActionEvent(Object source, String command, SlideOperation operation,
                            MouseEvent mouseEvent, int tabIndex) {
    super(source, ActionEvent.ACTION_PERFORMED, command);
    this.tabIndex = tabIndex;
    this.mouseEvent = mouseEvent;
    this.slideOperation = operation;
}
 
Example 10
Source File: XTaskbarPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void menuItemCallback(MenuItem mi) {
    if (mi != null) {
        ActionEvent ae = new ActionEvent(mi, ActionEvent.ACTION_PERFORMED,
                mi.getActionCommand());
        try {
            XToolkit.awtLock();
            XToolkit.postEvent(XToolkit.targetToAppContext(ae.getSource()), ae);
        } finally {
            XToolkit.awtUnlock();
        }
    }
}
 
Example 11
Source File: ButtonColumn.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/** The button has been pressed. Stop editing and invoke the custom Action */
@Override
public void actionPerformed(final ActionEvent e) {
  final int row = table.convertRowIndexToModel(table.getEditingRow());
  fireEditingStopped();

  // Invoke the Action

  final ActionEvent event =
      new ActionEvent(table, ActionEvent.ACTION_PERFORMED, String.valueOf(row));
  action.actionPerformed(event);
}
 
Example 12
Source File: ThumbsExplorerPanel.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
protected void fireActionPerformed() {
  ActionEvent actionEvent = new ActionEvent(current, ActionEvent.ACTION_PERFORMED, "");
  Object[] listeners = listenersList.getListeners(ActionListener.class);
  for (Object lst : listeners) {
    ((ActionListener) lst).actionPerformed(actionEvent);
  }
}
 
Example 13
Source File: JdotxtImageCheckBox.java    From jdotxt with GNU General Public License v3.0 5 votes vote down vote up
public void setSelected(boolean isSelected) {
	if (isSelected) setIcon(selected);
	else setIcon(unselected);
	
	if (this.isSelected == isSelected) return;
	else {
		this.isSelected = isSelected;
		ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Toggle");
		super.fireActionPerformed(event);
	}
}
 
Example 14
Source File: JCommandButton.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Programmatically perform a "rollover" on the action area. This does the
 * same thing as if the user had moved the mouse over the action area of the
 * button.
 */
public void doActionRollover() {
    ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
            this.getActionModel().getActionCommand());
    // Guaranteed to return a non-null array
    RolloverActionListener[] listeners = this.getListeners(RolloverActionListener.class);
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length - 1; i >= 0; i--) {
        (listeners[i]).actionPerformed(ae);
    }
}
 
Example 15
Source File: AWTEvent.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an AWTEvent object with the specified source object and type.
 *
 * @param source the object where the event originated
 * @param id the event type
 */
public AWTEvent(Object source, int id) {
    super(source);
    this.id = id;
    switch(id) {
      case ActionEvent.ACTION_PERFORMED:
      case ItemEvent.ITEM_STATE_CHANGED:
      case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
      case TextEvent.TEXT_VALUE_CHANGED:
        consumed = true;
        break;
      default:
    }
}
 
Example 16
Source File: FilterComboBoxEditor.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
protected void fireActionEvent(String str) {
	Object listeners[] = listenerList.getListenerList();
	for (Object obj : listeners) {
		if (obj instanceof ActionListener) {
			ActionListener l = (ActionListener)obj;
	        ActionEvent actionEvent = new ActionEvent(editor, ActionEvent.ACTION_PERFORMED, editor.getText());
            l.actionPerformed(actionEvent);
		}
	}
}
 
Example 17
Source File: RadioInplaceEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS);
    fireActionPerformed(ae);
}
 
Example 18
Source File: TeamServicesConfigurable.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
public TeamServicesConfigurable() {
    applyEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, CMD_APPLY_CHANGES);
    resetEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, CMD_RESET_CHANGES);
}
 
Example 19
Source File: TabActionEvent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of TabActionEvent
 */
public TabActionEvent(Object source, String command, int tabIndex) {
    super(source, ActionEvent.ACTION_PERFORMED, command);
    this.tabIndex = tabIndex;
    consumed = false;
}
 
Example 20
Source File: InputHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Executes the specified action, repeating and recording it as necessary.
 * 
 * @param listener
 *            The action listener
 * @param source
 *            The event source
 * @param actionCommand
 *            The action command
 */
public void executeAction(ActionListener listener, Object source, String actionCommand) {
	// create event
	ActionEvent evt = new ActionEvent(source, ActionEvent.ACTION_PERFORMED, actionCommand);

	// don't do anything if the action is a wrapper
	// (like EditAction.Wrapper)
	if (listener instanceof Wrapper) {
		listener.actionPerformed(evt);
		return;
	}

	// remember old values, in case action changes them
	boolean _repeat = repeat;
	int _repeatCount = getRepeatCount();

	// execute the action
	if (listener instanceof InputHandler.NonRepeatable) {
		listener.actionPerformed(evt);
	} else {
		for (int i = 0; i < Math.max(1, repeatCount); i++) {
			listener.actionPerformed(evt);
		}
	}

	// do recording. Notice that we do no recording whatsoever
	// for actions that grab keys
	if (grabAction == null) {
		if (recorder != null) {
			if (!(listener instanceof InputHandler.NonRecordable)) {
				if (_repeatCount != 1) {
					recorder.actionPerformed(REPEAT, String.valueOf(_repeatCount));
				}

				recorder.actionPerformed(listener, actionCommand);
			}
		}

		// If repeat was true originally, clear it
		// Otherwise it might have been set by the action, etc
		if (_repeat) {
			repeat = false;
			repeatCount = 0;
		}
	}
}