Time for action – implementing the game UI
We are ready to implement the UI part of the game. We will code everything in five methods: init
(to initialize and wire up all the UI components), itemClick
(to handle the clicks the user makes on the table), nextTurn
(to update the UI on each turn), gameOver
(to show the results when the game finishes), and getWords
(that will return a collection with the correct words in the table). The steps for implementing the UI part of the game are as follows:
First step as always is to create a new Vaadin project. We are using boxwords for the name of the project.
Browse the book's source code and copy the
Dictionary
andGame
classes and paste them beside yourBoxwordsUI
class. These classes implement the business logic for our game.Open your UI class (
BoxwordsUI
in this example) and add the following members:public class BoxwordsUI extends UI { private Game game = new Game(5); private Table table = new Table(); private VerticalLayout messagesLayout...