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 – listening to clicks

Following are the steps to add the corresponding UI logic for the table clicking part:

  1. Implement the itemClick method as follows:
    BoxwordsUI extends UI implements ItemClickListener {
    
      // ...
    
      public void itemClick(ItemClickEvent event) {
        Property property = event.getItem().getItemProperty(
    event.getPropertyId());
    
        if (".".equals(property.getValue())) {
          property.setValue(game.getCurrentLetter());
          nextTurn();
    
        } else {
          Notification.show("You must select an empty cell.");
        }
      }
    
      // ...
    
    }
  2. Run the application and perform some clicks on the table.

What just happened?

The event variable gives us all we need to know about the performed click. We are using an ItemClickListener , right? This means that our method will be called ...

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