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 ...

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.