O'Reilly logo

Vaadin 7 UI Design By Example Beginner's Guide by Alejandro Duarte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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,

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required