Java Code Examples for java.awt.EventQueue#getCurrentEvent()

The following examples show how to use java.awt.EventQueue#getCurrentEvent() . 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: SeaGlassTextFieldUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * DOCUMENT ME!
 *
 * @param action DOCUMENT ME!
 */
protected void fireAction(ActionListener action) {
    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 = new ActionEvent(getComponent(), ActionEvent.ACTION_PERFORMED, getComponent().getText(),
                                    EventQueue.getMostRecentEventTime(), modifiers);

    action.actionPerformed(e);
}
 
Example 2
Source File: BaseTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = bt.getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
Example 3
Source File: JFileChooser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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.
 *
 * @param command a string that may specify a command associated with
 *                the event
 * @see EventListenerList
 */
@SuppressWarnings("deprecation")
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);
        }
    }
}
 
Example 4
Source File: JFileChooser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 *
 * @param command a string that may specify a command associated with
 *                the event
 * @see EventListenerList
 */
@SuppressWarnings("deprecation")
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);
        }
    }
}
 
Example 5
Source File: JFileChooser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 6
Source File: JFileChooser.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 7
Source File: DialogDisplayerImplTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void postInAwtAndWaitOutsideAwt (final Runnable run) throws Exception {
        // pendig to better implementation
        SwingUtilities.invokeLater (run);
//        Thread.sleep (10);
        while (EventQueue.getCurrentEvent () != null) {
//            Thread.sleep (10);
        }
    }
 
Example 8
Source File: BaseTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);

    try {
        Container con = BaseTable.this.getFocusCycleRootAncestor();

        if (con != null) {
            Component target = BaseTable.this;

            if (getParent() instanceof JViewport) {
                target = getParent().getParent();

                if (target == con) {
                    target = BaseTable.this;
                }
            }

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;

            if (eo instanceof KeyEvent) {
                backward = ((((KeyEvent) eo).getModifiers() & KeyEvent.SHIFT_MASK) != 0) &&
                    ((((KeyEvent) eo).getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);
            }

            Component to = backward ? con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this)
                                    : con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this);

            if (to == BaseTable.this) {
                to = backward ? con.getFocusTraversalPolicy().getFirstComponent(con)
                              : con.getFocusTraversalPolicy().getLastComponent(con);
            }

            to.requestFocus();
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
Example 9
Source File: JFileChooser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 10
Source File: JFileChooser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 11
Source File: JFileChooser.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 12
Source File: JFileChooser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 13
Source File: JFileChooser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 14
Source File: JFileChooser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 15
Source File: JFileChooser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 16
Source File: JFileChooser.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
 */
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);
        }
    }
}
 
Example 17
Source File: BaseTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void trySendEscToDialog(JTable jt) {
    //        System.err.println("SendEscToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ESCAPE)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        InputMap imp = jt.getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = jt.getRootPane().getActionMap();

        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);

        if (key != null) {
            Action a = am.get(key);

            if (a != null) {
                if (Boolean.getBoolean("netbeans.proppanel.logDialogActions")) { //NOI18N
                    System.err.println("Action bound to escape key is " + a); //NOI18N
                }

                //Actions registered with deprecated registerKeyboardAction will
                //need this lookup of the action command
                String commandKey = (String) a.getValue(Action.ACTION_COMMAND_KEY);

                if (commandKey == null) {
                    commandKey = "cancel"; //NOI18N
                }

                a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
 
Example 18
Source File: EditorPropertyDisplayer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final void replaceInner() {
    inReplaceInner = true;

    try {
        Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
        boolean hadFocus = isEnabled() &&
            ((focusOwner == this) || isAncestorOf(focusOwner) ||
            ((getInplaceEditor() != null) && getInplaceEditor().isKnownComponent(focusOwner)));

        //Figure out if a combo popup was open, so we can re-open it.
        //If we're processing a mouse event, close it because that's
        //the normal behavior of a popup.  We want arrow keyboard events
        //to not trigger closing of the popup if they caused a change
        //to a value that is marked as invalid
        boolean wasComboPopup = hadFocus && focusOwner instanceof JComboBox &&
            ((JComboBox) focusOwner).isPopupVisible() &&
            (EventQueue.getCurrentEvent() instanceof KeyEvent &&
            ((((KeyEvent) EventQueue.getCurrentEvent()).getKeyCode() == KeyEvent.VK_UP) ||
            (((KeyEvent) EventQueue.getCurrentEvent()).getKeyCode() == KeyEvent.VK_DOWN)));

        //            System.err.println("REPLACE INNER - " + prop.getDisplayName() + " focus:" + hadFocus);
        if (hadFocus) {
            //We don't want focus to jump to another component and back
            KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
        }

        setInplaceEditor(createInplaceEditor());

        if (hadFocus) {
            requestFocus();

            //At this point the focus owner is still null, the event is queued - 
            if (wasComboPopup) {
                //We have to let the request focus on the event queue get
                //processed before this can be done, or the component will
                //not yet be laid out and the popup will be 1 pixel wide
                SwingUtilities.invokeLater(
                    new Runnable() {
                        public void run() {
                            InplaceEditor ied = getInplaceEditor();
                            ied = PropUtils.findInnermostInplaceEditor(ied);

                            JComponent c = ied.getComponent();

                            if (c instanceof JComboBox && c.isShowing()) {
                                ((JComboBox) c).showPopup();
                            }
                        }
                    }
                );
            }
        }

        revalidate();
        repaint();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        inReplaceInner = false;
    }
}
 
Example 19
Source File: ETable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);
    try {
        Container con = ETable.this.getFocusCycleRootAncestor();
        if (con != null) {
            /*
            Component target = ETable.this;
            if (getParent() instanceof JViewport) {
                target = getParent().getParent();
                if (target == con) {
                    target = ETable.this;
                }
            }
            */

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;
            if (eo instanceof KeyEvent) {
                backward = 
                    (((KeyEvent) eo).getModifiers() 
                    & KeyEvent.SHIFT_MASK) 
                    != 0 && (((KeyEvent) eo).getModifiersEx() & 
                    KeyEvent.SHIFT_DOWN_MASK) != 0;
            }

            Component c = ETable.this;
            Component to;
            Container parentWithFTP = null;
            do {
                FocusTraversalPolicy ftp = con.getFocusTraversalPolicy();
                to = backward ? ftp.getComponentBefore(con, c)
                              : ftp.getComponentAfter(con, c);


                if (to == ETable.this) {
                    to = backward ? ftp.getFirstComponent(con)
                                  : ftp.getLastComponent(con);
                }
                if (to == ETable.this) {
                    parentWithFTP = con.getParent();
                    if (parentWithFTP != null) {
                        parentWithFTP = parentWithFTP.getFocusCycleRootAncestor();
                    }
                    if (parentWithFTP != null) {
                        c = con;
                        con = parentWithFTP;
                    }
                }
            } while (to == ETable.this && parentWithFTP != null);
            if (to != null) {
                to.requestFocus();
            }
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
Example 20
Source File: SwingUtilities2.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Returns true if EventQueue.getCurrentEvent() has the permissions to
 * access the system clipboard and if it is allowed gesture (if
 * checkGesture true)
 *
 * @param checkGesture boolean
 */
private static boolean canCurrentEventAccessSystemClipboard(boolean
                                                           checkGesture) {
    AWTEvent event = EventQueue.getCurrentEvent();
    return canEventAccessSystemClipboard(event, checkGesture);
}