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

The following examples show how to use java.awt.event.ActionEvent#ACTION_PERFORMED . 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: jdk8u-jdk   File: Util.java    License: 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 Project: TencentKona-8   File: Util.java    License: 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 Project: jdk8u-jdk   File: Util.java    License: 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
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
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 6
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 7
Source Project: Bytecoder   File: AWTEvent.java    License: 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 8
/**
 * 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 9
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 10
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 11
/** 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
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 13
Source Project: netbeans   File: SlideBarActionEvent.java    License: 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 14
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 15
@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 16
Source Project: jdal   File: Selector.java    License: 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 17
/**
 * 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;
		}
	}
}
 
Example 18
Source Project: netbeans   File: RadioInplaceEditor.java    License: 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 19
public TeamServicesConfigurable() {
    applyEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, CMD_APPLY_CHANGES);
    resetEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, CMD_RESET_CHANGES);
}
 
Example 20
Source Project: netbeans   File: TabActionEvent.java    License: 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;
}