Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could push your own event queue which would give you total control of events. For example:</p> <pre><code> class SchedulingEventQueue extends EventQueue { // Use Map&lt; AWTEvent, List&lt; AWTEvent &gt; &gt; to support multiple events private final Map&lt; AWTEvent, AWTEvent &gt; eventSchedule = new HashMap&lt; AWTEvent, AWTEvent &gt;(); public void scheduleEvent( final AWTEvent event, final AWTEvent dependentEvent ) { eventSchedule.put( dependentEvent, event ); } @Override protected void dispatchEvent( final AWTEvent event ) { try { super.dispatchEvent( event ); } finally { // Dispatch any dependent event AWTEvent scheduledEvent = eventSchedule.remove( event ); if( scheduledEvent != null ) { postEvent( scheduledEvent ); } } } } // Now the code to post the events becomes: { SchedulingEventQueue eventQueue = new SchedulingEventQueue(); Toolkit.getDefaultToolkit().getSystemEventQueue().push( eventQueue ); MouseEvent pressEvent = new MouseEvent(target, MouseEvent.MOUSE_PRESSED, ...) MouseEvent releaseEvent = new MouseEvent(target, MouseEvent.MOUSE_RELEASED, ...) MouseEvent clickEvent = new MouseEvent(target, MouseEvent.MOUSE_CLICKED, ...) eventQueue.scheduleEvent( clickEvent, releaseEvent ); eventQueue.scheduleEvent( releaseEvent, pressEvent ); eventQueue.postEvent( pressEvent ); } </code></pre> <p>You just chain the events together so that they don't get posted until the previous event has been dispatched allowing any intermediate events created by a component to be posted during dispatch before your next event is posted. I haven't tried this but it should work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload