Example usage for java.awt EventQueue getMostRecentEventTime

List of usage examples for java.awt EventQueue getMostRecentEventTime

Introduction

In this page you can find the example usage for java.awt EventQueue getMostRecentEventTime.

Prototype

public static long getMostRecentEventTime() 

Source Link

Document

Returns the timestamp of the most recent event that had a timestamp, and that was dispatched from the EventQueue associated with the calling thread.

Usage

From source file:com.googlecode.vfsjfilechooser2.VFSJFileChooser.java

/**
 * Notifies all listeners that have registered interest for
 * notification on this event type. The event instance
 * is lazily created using the <code>command</code> parameter.
 *
 * @see EventListenerList/*  w w w  .  j a va2 s.  c  om*/
 */
protected void fireActionPerformed(String command) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    long mostRecentEventTime = EventQueue.getMostRecentEventTime();
    int modifiers = 0;
    AWTEvent currentEvent = EventQueue.getCurrentEvent();

    if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
    } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
    }

    ActionEvent e = null;

    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, command, mostRecentEventTime,
                        modifiers);
            }

            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Copy the selected data cells to the clipboard
 *///from www.  ja  v  a  2  s .co  m
private void copySelectionToClipboard() {
    Action objlCopy;

    try {
        objlCopy = TransferHandler.getCopyAction();
        objlCopy.actionPerformed(new ActionEvent(table, ActionEvent.ACTION_PERFORMED,
                (String) objlCopy.getValue(Action.NAME), EventQueue.getMostRecentEventTime(), 0));
    } catch (Throwable any) {
        LOGGER.error("Failed to copy data to clipboard", any);
        JOptionPane.showMessageDialog(this,
                Resources.getString("errClipboardCopyDataText", any.getClass().getName(),
                        any.getMessage() != null ? any.getMessage() : ""),
                Resources.getString("errClipboardCopyDataTitle"), JOptionPane.ERROR_MESSAGE);
    }
}