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-overview.asciidoc 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ---
  2. title: Overview
  3. order: 1
  4. layout: page
  5. ---
  6. [[layout.overview]]
  7. = Overview
  8. The user interface components in Vaadin can roughly be divided in two groups:
  9. components that the user can interact with and layout components for placing the
  10. other components to specific places in the user interface.
  11. The layout components are identical in their purpose to layout managers in regular desktop frameworks for Java.
  12. You can use plain Java to accomplish sophisticated component layouts.
  13. [[figure.layout.intro.simple]]
  14. .Layout example
  15. image::img/layout-intro-example-1.png[width=75%, scaledwidth=100%]
  16. You start by creating a content layout for the UI and then add other layout
  17. components hierarchically, and finally the interaction components as the leaves
  18. of the component tree.
  19. [[figure.layout.intro.schematic]]
  20. .Layout schematic
  21. image::img/layout-schematic.png[width=100%, scaledwidth=100%]
  22. Let us look at building a bit simplified version of the layout in <<figure.layout.intro.simple>>:
  23. [source, java]
  24. ----
  25. // Set the root layout for the UI
  26. VerticalLayout content = new VerticalLayout();
  27. setContent(content);
  28. HorizontalLayout titleBar = new HorizontalLayout();
  29. titleBar.setWidth("100%");
  30. root.addComponent(titleBar);
  31. Label title = new Label("The Ultimate Cat Finder");
  32. titleBar.addComponent(title);
  33. titleBar.setExpandRatio(title, 1.0f); // Expand
  34. Label titleComment = new Label("for Vaadin");
  35. titleComment.setSizeUndefined(); // Take minimum space
  36. titleBar.addComponent(titleComment);
  37. ... build rest of the layout ...
  38. ----
  39. Or in the declarative format (roughly):
  40. [source, html]
  41. ----
  42. <vaadin-vertical-layout>
  43. <vaadin-label>The Ultimate Cat Finder</vaadin-label>
  44. <vaadin-horizontal-layout>
  45. <vaadin-radio-button-group caption="Possible Places"/>
  46. <vaadin-panel/>
  47. ...
  48. </vaadin-horizontal-layout>
  49. </vaadin-vertical-layout>
  50. ----
  51. You will usually need to tune the layout components a bit by setting sizes,
  52. expansion ratios, alignments, spacings, and so on. The general settings are
  53. described in
  54. <<layout-settings#layout.settings,"Layout
  55. Formatting">>.
  56. Layouts are coupled with themes that specify various layout features, such as
  57. backgrounds, borders, text alignment, and so on. Definition and use of themes is
  58. described in
  59. <<../themes/themes-overview.asciidoc#themes.overview,"Themes">>.
  60. You can see a finished version of the above example in
  61. <<figure.layout.intro.simple>>.