Time for action – using panels
Let's add a panel using our framework application.
In
LayoutFrameworkUI
class, add agetPanel
method and call it from theinit
method to add the returned component to our main layout:public class LayoutFrameworkUI extends UI { protected void init(VaadinRequest request) { ... layout.addMenuOption("Panel", getPanel()); } ... private Panel getPanel() { String someNumbers = ""; for (int i = 0; i < 2000; i++) { someNumbers += " " + i; } Label content = new Label(someNumbers); Panel panel = new Panel("Panel's caption", content); panel.setWidth("200px"); panel.setHeight("100px"); panel.setScrollTop(3000); // pixels from top return panel; } }
Run it!
What just happened?
Here is a screenshot of the application showing the panel:
Let's take a closer look at how we created the panel
instance. First, we created a String
with a lot of numbers in it. Then, we created a new Label
as usual using the numbers...