Time for action – adding click listeners

Follow these steps to allow a VerticalLayout listen to click events:

  1. Once again, add the highlighted code to your each time bigger (and it will grow more, you can tell) LayoutFrameworkUI class:
    public class LayoutFrameworkUI extends UI {
    
      protected void init(VaadinRequest request) {
    
        ...
        layout.addMenuOption("Click listener",
            getClickListener());
      }
    
      ...
    
      private Component getClickListener() {
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeFull();
        layout.addLayoutClickListener(new LayoutClickListener() {
          public void layoutClick(LayoutClickEvent event) {
            String message = "And you did it at "
                + event.getClientX() + ", "
                + event.getClientY();
            Notification.show("You clicked me!", message,

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.