Java Code Examples for com.vaadin.flow.component.html.Div#setWidth()

The following examples show how to use com.vaadin.flow.component.html.Div#setWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DnDCustomComponentView.java    From flow with Apache License 2.0 7 votes vote down vote up
public DraggableItem(EffectAllowed effectAllowed) {
    dragHandle = new Div();
    dragHandle.setHeight("50px");
    dragHandle.setWidth("80px");
    dragHandle.getStyle().set("background", "#000 ");
    dragHandle.getStyle().set("margin", "5 10px");
    dragHandle.getStyle().set("display", "inline-block");

    setDraggable(true);
    setDragData(effectAllowed);
    addDragStartListener(DnDCustomComponentView.this::onDragStart);
    addDragEndListener(DnDCustomComponentView.this::onDragEnd);

    setHeight("50px");
    setWidth("200px");
    getStyle().set("border", "1px solid black");
    getStyle().set("display", "inline-block");

    add(dragHandle, new Span(effectAllowed.toString()));
}
 
Example 2
Source File: LeftAppMenuBuilder.java    From vaadin-app-layout with Apache License 2.0 6 votes vote down vote up
public Component build() {
    components.addAll(header);
    LeftMenuComponentWrapper menu = new LeftMenuComponentWrapper();
    components.addAll(body);
    if (sticky) {
        menu.getMenu().getStyle().set("display", "flex");
        Div div = new Div();
        div.setWidth("100%");
        div.setHeight("0px");
        div.getStyle().set("flex", "1 1");
        components.add(div);
    }
    components.addAll(footer);
    menu.add(components.toArray(new Component[0]));
    return menu;
}
 
Example 3
Source File: DnDDisabledView.java    From flow with Apache License 2.0 6 votes vote down vote up
private void createEventLog() {
    eventLog = new Div();
    eventLog.add(new Text("Events:"));
    eventLog.add(new NativeButton("Clear", event -> {
        eventLog.getChildren().filter(component -> component instanceof Div)
                .forEach(eventLog::remove);
        eventCounter = 0;
    }));
    eventLog.add(new NativeButton("Data: " + data, event -> {
        data = !data;
        event.getSource().setText("Data: " + data);
    }));
    eventLog.setHeightFull();
    eventLog.setWidth("400px");
    eventLog.getStyle().set("display", "inline-block").set("border",
            "2px " + "solid");
}
 
Example 4
Source File: TopLayouts.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
public Top() {
    contentPanel.setSizeFull();
    getElement().getClassList().addAll(Arrays.asList("app-layout-behaviour-" + getStyleName(), "app-layout"));
    appBar.add(titleWrapper, paperTabWrapper, appBarElementWrapper);
    paperTabWrapper.setFlexGrow(1.0, titleWrapper);
    paperTabWrapper.setWidth("100%");
    paperTabWrapper.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
    appBar.setWidth("100%");
    appBar.setHeight("100%");

    appBarElements = new Div();
    appBarElements.setHeight("100%");
    appBarElements.getElement().setAttribute("slot", "app-bar-content");
    contentHolder = new Div();
    contentHolder.setHeight("100%");
    contentHolder.setWidth("100%");
    contentHolder.getElement().setAttribute("slot", "application-content");

    appBarElements.add(appBar);
    appBarElementWrapper.setSpacing(false);
    appBarElementWrapper.add(appBarElementContainer);
    appBarElementContainer.setHeight("100%");
    appBarElementWrapper.setAlignItems(FlexComponent.Alignment.START);
    titleWrapper.setHeight("100%");
    titleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
    menuButton.setIcon(VaadinIcon.ARROW_LEFT.create());
    menuButton.addThemeNames(ButtonVariant.LUMO_TERTIARY.getVariantName(), ButtonVariant.LUMO_ICON.getVariantName(), ButtonVariant.LUMO_LARGE.getVariantName());
    getElement().appendChild(appBarElements.getElement(), contentHolder.getElement());
}
 
Example 5
Source File: DnDView.java    From flow with Apache License 2.0 5 votes vote down vote up
private Div createBox(String identifier) {
    Div box = new Div();
    box.setText(identifier);
    box.setWidth("100px");
    box.setHeight("60px");
    box.getStyle().set("border", "1px solid").set("margin", "10px");
    box.setId("box-" + identifier);
    return box;
}
 
Example 6
Source File: DnDView.java    From flow with Apache License 2.0 5 votes vote down vote up
private Div createLane(String identifier) {
    Div lane = new Div();
    lane.add(identifier);
    lane.setId("lane-" + identifier);
    lane.getStyle().set("margin", "20px").set("border", "1px solid black")
            .set("display", "inline-block");
    lane.setHeightFull();
    lane.setWidth("150px");
    return lane;
}
 
Example 7
Source File: DnDDisabledView.java    From flow with Apache License 2.0 5 votes vote down vote up
private Div createBox(String identifier) {
    Div box = new Div();
    box.setText(identifier);
    box.setWidth("100px");
    box.setHeight("60px");
    box.getStyle().set("border", "1px solid").set("margin", "10px");
    box.setId("box-" + identifier);
    return box;
}
 
Example 8
Source File: DnDDisabledView.java    From flow with Apache License 2.0 5 votes vote down vote up
private Div createLane(String identifier) {
    Div lane = new Div();
    lane.add(identifier);
    lane.setId("lane-" + identifier);
    lane.getStyle().set("margin", "20px").set("border", "1px solid black")
            .set("display", "inline-block");
    lane.setHeightFull();
    lane.setWidth("150px");
    return lane;
}
 
Example 9
Source File: DnDCustomComponentView.java    From flow with Apache License 2.0 5 votes vote down vote up
public DnDCustomComponentView() {
    Stream.of(EffectAllowed.values()).map(DraggableItem::new)
            .forEach(this::add);

    dropTarget = new Div();
    dropTarget.add(new Text("Drop Here"));
    dropTarget.setWidth("200px");
    dropTarget.setHeight("200px");
    dropTarget.getStyle().set("border", "solid 1px pink");
    add(dropTarget);

    DropTarget.create(dropTarget).addDropListener(event -> event.getSource()
            .add(new Span(event.getDragData().get().toString())));
}
 
Example 10
Source File: DnDView.java    From flow with Apache License 2.0 4 votes vote down vote up
public DnDView() {
    setWidth("1000px");
    setHeight("800px");
    getStyle().set("display", "flex");

    eventLog = new Div();
    eventLog.add(new Text("Events:"));
    eventLog.add(new NativeButton("Clear", event -> {
        eventLog.getChildren().filter(component -> component instanceof Div)
                .forEach(eventLog::remove);
        eventCounter = 0;
    }));
    eventLog.add(new NativeButton("Data: " + data, event -> {
        data = !data;
        event.getSource().setText("Data: " + data);
    }));
    eventLog.setHeightFull();
    eventLog.setWidth("400px");
    eventLog.getStyle().set("display", "inline-block").set("border",
            "2px " + "solid");
    add(eventLog);

    Div startLane = createLane("start");
    startLane.add(createDraggableBox(null));
    Stream.of(EffectAllowed.values()).map(this::createDraggableBox)
            .forEach(startLane::add);

    Div noEffectLane = createDropLane(null);
    Div copyDropLane = createDropLane(DropEffect.COPY);
    Div moveDropLane = createDropLane(DropEffect.MOVE);
    Div linkDropLane = createDropLane(DropEffect.LINK);
    Div noneDropLane = createDropLane(DropEffect.NONE);

    Div deactivatedLane = createDropLane(DropEffect.COPY);
    deactivatedLane.setId("lane-deactivated");
    deactivatedLane.getChildren().findFirst().ifPresent(
            component -> component.getElement().setText("deactivated"));
    DropTarget.configure(deactivatedLane, false);

    eventLog.add(createToggleDropTargetsButton(noEffectLane, copyDropLane,
            moveDropLane, linkDropLane, noneDropLane));
    eventLog.add(createToggleDragSourcesButton(startLane));

    add(startLane, noEffectLane, copyDropLane, moveDropLane, linkDropLane,
            noneDropLane, deactivatedLane);
}