Implementing a Listener

Implementing a Listener


// Here we have a composite component that handles the
// events of its sub-components (a single button).
public class MyComposition extends CustomComponent
                           implements Button.ClickListener {
    public MyComposition() {
        
        // Just a single component in this composition.
        Button button = new Button("Click Me!");

        // You could also give the listener (this) in the
        // Constructor.
        button.addListener(this);
        
        setCompositionRoot(button);
    }
    
    // The listener method implementation
    public void buttonClick(ClickEvent event) {
        getWindow().showNotification("Thank You!");
    }
}