Example usage for java.awt EventQueue getCurrentEvent

List of usage examples for java.awt EventQueue getCurrentEvent

Introduction

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

Prototype

public static AWTEvent getCurrentEvent() 

Source Link

Document

Returns the event currently being dispatched by the EventQueue associated with the calling thread.

Usage

From source file:Main.java

public static boolean isPasteAction() {
    AWTEvent e = EventQueue.getCurrentEvent();
    if (e != null && e.getID() == KeyEvent.KEY_PRESSED) {
        KeyEvent k = (KeyEvent) e;
        if (k.getKeyCode() == KeyEvent.VK_V && k.getModifiers() == KeyEvent.CTRL_MASK) {
            return true;
        }// www. jav  a2 s  .c o m
    }
    return false;
}

From source file:Main.java

/**
 * Returns true if EventQueue.getCurrentEvent() has the permissions to
 * access the system clipboard and if it is allowed gesture (if
 * checkGesture true)/*from  w ww  .  jav a2  s  .c o m*/
 *
 * @param checkGesture boolean
 */
private static boolean canCurrentEventAccessSystemClipboard(boolean checkGesture) {
    AWTEvent event = EventQueue.getCurrentEvent();
    return canEventAccessSystemClipboard(event, checkGesture);
}

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 ww.j a  va  2s . c o m*/
 */
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:org.nuclos.client.ui.collect.SubForm.java

public void fireFocusGained() {
    AWTEvent event = EventQueue.getCurrentEvent();
    if (event instanceof KeyEvent) {
        if (getJTable().getModel().getRowCount() > 0) {
            getJTable().editCellAt(0, 0);
            getSubformTable().changeSelection(0, 0, false, false);
        } else if (getJTable().getModel().getRowCount() == 0) {
            for (FocusActionListener fal : getFocusActionLister()) {
                fal.focusAction(new EventObject(this));
                if (getJTable().editCellAt(0, 0)) {
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            Component editor = getJTable().getEditorComponent();
                            if (editor != null)
                                editor.requestFocusInWindow();
                        }// ww w  . jav  a  2 s. c o  m
                    });

                }
            }
        }
    }
}