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 – finishing the game

Following are the steps to complete our game:

  1. The nextTurn method checks if the game is over. If so, it will delegate control to the gameOver method, or else, it will generate the next random letter (by calling the game.nextLetter() method) and will update the label showing the new letter. As you have seen in previous snippets, this method is called every time the user clicks on an empty cell. Here is the implementation:
    public class BoxwordsUI extends UI implements ItemClickListener {
    
      // ...
    
      private void nextTurn() {
        if (game.over()) {
          gameOver();
    
        } else {
          currentLetter.setValue("Next letter: "+ game.nextLetter());
        }
      }
    
      // ...
    
    }
  2. The gameOver method updates the UI to show the score and correct words. For each word, ...

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