iam stuck at some maybe simple thing in Vaadin 10.
I have a Horizontal Layout with two Buttons. One for saving the fields and one to close the dialog.
Now i want to align the save button to the left and the close button to the right.
In Vaadin 8 i set the layout to fullSize ord maxwidth and then use this:
FYI, there’s a pure JAVA solution on Vaadin 14, which is explained in the [Layouting tutorial]
(https://vaadin.com/learn/training/v14-layouting). Starting at page 50 of the tutorial’s handout PDF, there’s an example for implementing left and right aligned components inside a HorizontalLayout. Page 51 shows a pure JAVA solution, as in the following confirmation dialog example:
Dialog confirmDialog = new Dialog();
Paragraph confirmText = new Paragraph("Are you sure you want to leave this page?");
Button confirmButton = new Button("Confirm");
Button cancelButton = new Button("Cancel");
// Add a FlexLayout wrapper for the element you want to right align
FlexLayout cancelButtonWrapper = new FlexLayout(cancelButton);
// Set the wrapper flex alignment to end (right)
cancelButtonWrapper.setJustifyContentMode(JustifyContentMode.END);
// Create the HorizontalLayout and expand the wrapper component
HorizontalLayout dialogButtons = new HorizontalLayout(confirmButton, cancelButtonWrapper);
dialogButtons.expand(cancelButtonWrapper);
// Add the components to the dialog
confirmDialog.add(confirmText, dialogButtons);
confirmDialog.open();
At page 52 the CSS solution is mentioned as an alternative.
Button cancel = new Button("Cancel");
Button save = new Button("Save");
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.setJustifyContentMode(JustifyContentMode.BETWEEN);
buttonLayout.add(save, cancel);