java.awt

Class EventQueue


  • public class EventQueue
    extends Object
    EventQueue is a platform-independent class that queues events, both from the underlying peer classes and from trusted application classes.

    It encapsulates asynchronous event dispatch machinery which extracts events from the queue and dispatches them by calling dispatchEvent(AWTEvent) method on this EventQueue with the event to be dispatched as an argument. The particular behavior of this machinery is implementation-dependent. The only requirements are that events which were actually enqueued to this queue (note that events being posted to the EventQueue can be coalesced) are dispatched:

    Sequentially.
    That is, it is not permitted that several events from this queue are dispatched simultaneously.
    In the same order as they are enqueued.
    That is, if AWTEvent A is enqueued to the EventQueue before AWTEvent B then event B will not be dispatched before event A.

    Some browsers partition applets in different code bases into separate contexts, and establish walls between these contexts. In such a scenario, there will be one EventQueue per context. Other browsers place all applets into the same context, implying that there will be only a single, global EventQueue for all applets. This behavior is implementation-dependent. Consult your browser's documentation for more information.

    For information on the threading issues of the event dispatch machinery, see AWT Threading Issues.

    Since:
    1.1
    • Constructor Detail

      • EventQueue

        public EventQueue()
    • Method Detail

      • postEvent

        public void postEvent(AWTEvent theEvent)
        Posts a 1.1-style event to the EventQueue. If there is an existing event on the queue with the same ID and event source, the source Component's coalesceEvents method will be called.
        Parameters:
        theEvent - an instance of java.awt.AWTEvent, or a subclass of it
        Throws:
        NullPointerException - if theEvent is null
      • getNextEvent

        public AWTEvent getNextEvent()
                              throws InterruptedException
        Removes an event from the EventQueue and returns it. This method will block until an event has been posted by another thread.
        Returns:
        the next AWTEvent
        Throws:
        InterruptedException - if any thread has interrupted this thread
      • peekEvent

        public AWTEvent peekEvent()
        Returns the first event on the EventQueue without removing it.
        Returns:
        the first event
      • peekEvent

        public AWTEvent peekEvent(int id)
        Returns the first event with the specified id, if any.
        Parameters:
        id - the id of the type of event desired
        Returns:
        the first event of the specified id or null if there is no such event
      • dispatchEvent

        protected void dispatchEvent(AWTEvent event)
        Dispatches an event. The manner in which the event is dispatched depends upon the type of the event and the type of the event's source object:

        Event Type Source Type Dispatched To
        ActiveEvent Any event.dispatch()
        Other Component source.dispatchEvent(AWTEvent)
        Other MenuComponent source.dispatchEvent(AWTEvent)
        Other Other No action (ignored)

        Eerste pagina van API Java Inhoudsopgave Haut

        Parameters:
        event - an instance of java.awt.AWTEvent, or a subclass of it
        Throws:
        NullPointerException - if event is null
        Since:
        1.2
      • getMostRecentEventTime

        public static long getMostRecentEventTime()
        Returns the timestamp of the most recent event that had a timestamp, and that was dispatched from the EventQueue associated with the calling thread. If an event with a timestamp is currently being dispatched, its timestamp will be returned. If no events have yet been dispatched, the EventQueue's initialization time will be returned instead.In the current version of the JDK, only InputEvents, ActionEvents, and InvocationEvents have timestamps; however, future versions of the JDK may add timestamps to additional event types. Note that this method should only be invoked from an application's event dispatching thread. If this method is invoked from another thread, the current system time (as reported by System.currentTimeMillis()) will be returned instead.
        Returns:
        the timestamp of the last InputEvent, ActionEvent, or InvocationEvent to be dispatched, or System.currentTimeMillis() if this method is invoked on a thread other than an event dispatching thread
        Since:
        1.4
        See Also:
        InputEvent.getWhen(), ActionEvent.getWhen(), InvocationEvent.getWhen(), isDispatchThread()
      • getCurrentEvent

        public static AWTEvent getCurrentEvent()
        Returns the the event currently being dispatched by the EventQueue associated with the calling thread. This is useful if a method needs access to the event, but was not designed to receive a reference to it as an argument. Note that this method should only be invoked from an application's event dispatching thread. If this method is invoked from another thread, null will be returned.
        Returns:
        the event currently being dispatched, or null if this method is invoked on a thread other than an event dispatching thread
        Since:
        1.4
      • push

        public void push(EventQueue newEventQueue)
        Replaces the existing EventQueue with the specified one. Any pending events are transferred to the new EventQueue for processing by it.
        Parameters:
        newEventQueue - an EventQueue (or subclass thereof) instance to be use
        Throws:
        NullPointerException - if newEventQueue is null
        Since:
        1.2
        See Also:
        pop()
      • pop

        protected void pop()
                    throws EmptyStackException
        Stops dispatching events using this EventQueue. Any pending events are transferred to the previous EventQueue for processing.

        Warning: To avoid deadlock, do not declare this method synchronized in a subclass.

        Throws:
        EmptyStackException - if no previous push was made on this EventQueue
        Since:
        1.2
        See Also:
        push(java.awt.EventQueue)

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/awt/EventQueue.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut