Time for action – my first table
Following are the steps to create your first table:
Create a new Vaadin project named my-first-table using your IDE.
Edit your
UI
class to match the following code snippet:public class MyFirstTableUI extends UI { protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); } }
Now, add the actual code for the table shown as follows:
public class MyFirstTableUI extends UI { protected void init(VaadinRequest request) { // ... Table table = new Table(); table.addContainerProperty("Column 1", String.class, "(default 1)"); table.addContainerProperty("Column 2", String.class, "(default 2)"); table.addItem(new Object[] { "Hi", "There" }, "item ID 1"); table.addItem(new Object[] { "Well", "Hello!" }, "item ID 2"); table.addItem(); layout.addComponent(table); } }
Run it!
What just happened?
First of all, here is a screenshot of...