Edit the init
method of your
TimeItUI
class to match the following:
@Override protected void init(VaadinRequest request) { initCombo(); initButton(); initLayout(); }
Here we are breaking up the functionality to initialize our UI components in a more suitable way by implementing smaller methods. Now that we have the required infrastructure, we can start adding input components.
A combobox is an input component that allows users to select an option from a drop-down list. It looks like the following screenshot:
You must be thinking "yeah right, but how do you put those options in there?" This is easy:
ComboBox c = new ComboBox("Select an option"); c.addItem("Option one"); c.addItem("Option two"); c.addItem("Option three");
If you have the options in a Java Collection
class, you can pass the Collection
instance to the constructor like this:
ArrayList<String> options = new ArrayList<>();
options.add("Option...