use of java.awt.EventQueue in project jdk8u_jdk by JetBrains.
the class InputMethodEvent method getMostRecentEventTimeForSource.
/**
* Get the most recent event time in the {@code EventQueue} which the {@code source}
* belongs to.
*
* @param source the source of the event
* @exception IllegalArgumentException if source is null.
* @return most recent event time in the {@code EventQueue}
*/
private static long getMostRecentEventTimeForSource(Object source) {
if (source == null) {
// throw the IllegalArgumentException to conform to EventObject spec
throw new IllegalArgumentException("null source");
}
AppContext appContext = SunToolkit.targetToAppContext(source);
EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);
return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue);
}
use of java.awt.EventQueue in project hackpad by dropbox.
the class RunProxy method dispatchNextGuiEvent.
/**
* Processes the next GUI event.
*/
public void dispatchNextGuiEvent() throws InterruptedException {
EventQueue queue = awtEventQueue;
if (queue == null) {
queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
awtEventQueue = queue;
}
AWTEvent event = queue.getNextEvent();
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else {
Object source = event.getSource();
if (source instanceof Component) {
Component comp = (Component) source;
comp.dispatchEvent(event);
} else if (source instanceof MenuComponent) {
((MenuComponent) source).dispatchEvent(event);
}
}
}
use of java.awt.EventQueue in project jodd by oblac.
the class CaddyDialog method setVisible.
@Override
public void setVisible(boolean visible) {
boolean blockParent = (visible && modal);
owner.setEnabled(!blockParent);
owner.setFocusableWindowState(!blockParent);
super.setVisible(visible);
if (blockParent) {
owner.addWindowListener(parentWindowListener);
try {
if (SwingUtilities.isEventDispatchThread()) {
EventQueue theQueue = getToolkit().getSystemEventQueue();
while (isVisible()) {
AWTEvent event = theQueue.getNextEvent();
Object src = event.getSource();
if (event instanceof ActiveEvent) {
((ActiveEvent) event).dispatch();
} else if (src instanceof Component) {
((Component) src).dispatchEvent(event);
}
}
} else {
synchronized (getTreeLock()) {
while (isVisible()) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
owner.removeWindowListener(parentWindowListener);
// added 2 lines
owner.setEnabled(true);
owner.setFocusableWindowState(true);
}
}
use of java.awt.EventQueue in project jdk8u_jdk by JetBrains.
the class EDTShutdownTest method main.
public static void main(String[] args) {
// Force EDT start with InvocationEvent
EventQueue.invokeLater(() -> {
// EventQueue is empty now
EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
Thread thread = AWTAccessor.getEventQueueAccessor().getDispatchThread(queue);
try {
/*
* Clear EventDispatchThread.doDispatch flag to break message
* loop in EventDispatchThread.pumpEventsForFilter()
*/
Method stopDispatching = thread.getClass().getDeclaredMethod("stopDispatching", null);
stopDispatching.setAccessible(true);
stopDispatching.invoke(thread, null);
/*
* Post another InvocationEvent that must be handled by another
* instance of EDT
*/
EventQueue.invokeLater(() -> {
passed = true;
});
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
}
});
// Wait for EDT shutdown
EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
Thread thread = AWTAccessor.getEventQueueAccessor().getDispatchThread(queue);
try {
thread.join();
/*
* Wait for another EDT instance to handle the InvocationEvent
* and shutdown
*/
thread = AWTAccessor.getEventQueueAccessor().getDispatchThread(queue);
if (thread != null) {
thread.join();
}
} catch (InterruptedException e) {
}
if (passed) {
System.out.println("Test PASSED!");
} else {
throw new RuntimeException("Test FAILED!");
}
}
Aggregations