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 panels

Let's add a panel using our framework application.

  1. In LayoutFrameworkUI class, add a getPanel method and call it from the init 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;
      }
    
    }
  2. Run it!

What just happened?

Here is a screenshot of the application showing ...

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