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 – using text fields

Follow these steps to add some fun to our application:

  1. Change your code to add the required text fields just before the line that creates the button instance by adding the highlighted code:
    // ...
    setContent(layout);
            
    final TextField name1 = new TextField("Somebody's name");
    final TextField name2 = new TextField("somebody's name");
    layout.addComponent(name1);
    layout.addComponent(name2);
            
    Button button = new Button("Click Me");
    // ...
  2. Add the business logic in a new method like this:
    public String getFunnyPhrase(String name1, String name2) { String[] verbs = new String[] { "eats", "melts", "breaks", "washes", "sells"}; String[] bodyParts = new String[] { "head", "hands", "waist", "eyes", "elbows"}; return name1 + " ...

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