You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

layout-root-layout.asciidoc 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ---
  2. title: UI, Window, and Panel Content
  3. order: 2
  4. layout: page
  5. ---
  6. [[layout.root-layout]]
  7. = UI, Window, and Panel Content
  8. The [classname]#UI#, [classname]#Window#, and [classname]#Panel# all have a
  9. single content component, which you need to set with [methodname]#setContent()#.
  10. The content is usually a layout component, although any component is allowed.
  11. [source, java]
  12. ----
  13. Panel panel = new Panel("This is a Panel");
  14. VerticalLayout panelContent = new VerticalLayout();
  15. panelContent.addComponent(new Label("Hello!"));
  16. panel.setContent(panelContent);
  17. // Set the panel as the content of the UI
  18. setContent(panel);
  19. ----
  20. The size of the content is the default size of the particular layout component,
  21. for example, a [classname]#VerticalLayout# has 100% width and undefined height
  22. by default (this coincides with the defaults for [classname]#Panel# and
  23. [classname]#Label#). If such a layout with undefined height grows higher than
  24. the browser window, it will flow out of the view and scrollbars will appear. In
  25. many applications, you want to use the full area of the browser view. Setting
  26. the components contained inside the content layout to full size is not enough,
  27. and would actually lead to an invalid state if the height of the content layout
  28. is undefined.
  29. [source, java]
  30. ----
  31. // First set the root content for the UI
  32. VerticalLayout content = new VerticalLayout();
  33. setContent(content);
  34. // Set the content size to full width and height
  35. content.setSizeFull();
  36. // Add a title area on top of the screen. This takes
  37. // just the vertical space it needs.
  38. content.addComponent(new Label("My Application"));
  39. // Add a menu-view area that takes rest of vertical space
  40. HorizontalLayout menuview = new HorizontalLayout();
  41. menuview.setSizeFull();
  42. content.addComponent(menuview);
  43. ----
  44. See
  45. <<layout-settings#layout.settings.size,"Layout
  46. Size">> for more information about setting layout sizes.