Class Event

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    HasComponents.ComponentAttachEvent, HasComponents.ComponentDetachEvent, MouseEvents.ClickEvent

    public class Event
    extends com.vaadin.flow.component.ComponentEvent<com.vaadin.flow.component.Component>
    Legacy version of Event class that resembles Vaadin 7/8's Component.Event API as closely as possible in order to facilitate migration to newer versions of Vaadin. Superclass of all component originated events.

    Events are the basis of all user interaction handling in Vaadin. To handle events, you provide a listener object that receives the events of the particular event type.

     Button button = new Button("Click Me!");
     button.addListener(new Button.ClickListener() {
         public void buttonClick(ClickEvent event) {
             getWindow().showNotification("Thank You!");
         }
     });
     layout.addComponent(button);
     

    Notice that while each of the event types have their corresponding listener types; the listener interfaces are not required to inherit the com.vaadin.legacy.ui.Listener interface.

    See Also:
    Listener, Serialized Form
    • Field Summary

      • Fields inherited from class java.util.EventObject

        source
    • Constructor Summary

      Constructors 
      Constructor Description
      Event​(com.vaadin.flow.component.Component source)
      Constructs a new event with the specified source component.
      Event​(com.vaadin.flow.component.Component source, boolean fromClient)
      Creates a new event using the given source and indicator whether the event originated from the client side or the server side.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.vaadin.flow.component.Component getComponent()
      Gets the component where the event occurred.
      • Methods inherited from class com.vaadin.flow.component.ComponentEvent

        getSource, isFromClient, unregisterListener
      • Methods inherited from class java.util.EventObject

        toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Event

        public Event​(com.vaadin.flow.component.Component source)
        Constructs a new event with the specified source component.
        Parameters:
        source - the source component of the event
      • Event

        public Event​(com.vaadin.flow.component.Component source,
                     boolean fromClient)
        Creates a new event using the given source and indicator whether the event originated from the client side or the server side.
        Parameters:
        source - the source component
        fromClient - true if the event originated from the client side, false otherwise
    • Method Detail

      • getComponent

        public com.vaadin.flow.component.Component getComponent()
        Gets the component where the event occurred.
        Returns:
        the source component of the event