|
| 1 | +package com.vaadin.demo.component.basiclayouts; |
| 2 | + |
| 3 | +import com.vaadin.demo.DemoExporter; // hidden-source-line |
| 4 | +import com.vaadin.flow.component.html.Div; |
| 5 | +import com.vaadin.flow.component.button.Button; |
| 6 | +import com.vaadin.flow.component.orderedlayout.FlexComponent; |
| 7 | +import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
| 8 | +import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
| 9 | +import com.vaadin.flow.router.Route; |
| 10 | +import com.vaadin.flow.theme.lumo.LumoUtility.Margin.Minus.Horizontal; |
| 11 | + |
| 12 | +@Route("basic-layouts/vertical-layout-wrapping") |
| 13 | +public class BasicLayoutsVerticalLayoutWrapping extends Div { |
| 14 | + |
| 15 | + public BasicLayoutsVerticalLayoutWrapping() { |
| 16 | + HorizontalLayout parent = new HorizontalLayout(); |
| 17 | + parent.setSpacing(true); |
| 18 | + parent.setMargin(true); |
| 19 | + parent.getElement().getStyle().setBorder("0"); |
| 20 | + |
| 21 | + VerticalLayout layoutNoWrap = new VerticalLayout(); |
| 22 | + layoutNoWrap.setPadding(true); |
| 23 | + layoutNoWrap.setSpacing(true); |
| 24 | + layoutNoWrap.setAlignItems(FlexComponent.Alignment.STRETCH); |
| 25 | + layoutNoWrap.setHeight("200px"); |
| 26 | + layoutNoWrap.setWidthFull(); |
| 27 | + layoutNoWrap.add(new Button("Button 1")); |
| 28 | + layoutNoWrap.add(new Button("Button 2")); |
| 29 | + layoutNoWrap.add(new Button("Button 3")); |
| 30 | + layoutNoWrap.add(new Button("Button 4")); |
| 31 | + parent.add(layoutNoWrap); |
| 32 | + |
| 33 | + // tag::snippet[] |
| 34 | + VerticalLayout layout = new VerticalLayout(); |
| 35 | + layout.setPadding(true); |
| 36 | + layout.setSpacing(true); |
| 37 | + layout.setWrap(true); |
| 38 | + layout.setAlignItems(FlexComponent.Alignment.STRETCH); |
| 39 | + layout.setHeight("200px"); |
| 40 | + layout.setWidthFull(); |
| 41 | + layout.add(new Button("Button 1")); |
| 42 | + layout.add(new Button("Button 2")); |
| 43 | + layout.add(new Button("Button 3")); |
| 44 | + layout.add(new Button("Button 4")); |
| 45 | + // end::snippet[] |
| 46 | + |
| 47 | + parent.add(layout); |
| 48 | + this.setClassName("basic-layouts-example"); |
| 49 | + this.add(parent); |
| 50 | + } |
| 51 | + |
| 52 | + public static class Exporter // hidden-source-line |
| 53 | + extends DemoExporter<BasicLayoutsVerticalLayoutWrapping> { // hidden-source-line |
| 54 | + } // hidden-source-line |
| 55 | +} |
0 commit comments