I have been using the ConfirmDialog
add-on from the Vaadin Directory.
Is it possible to put the OK and Cancel buttons in the center of the window? By default it is in the right corner of the window.
I have been using the ConfirmDialog
add-on from the Vaadin Directory.
Is it possible to put the OK and Cancel buttons in the center of the window? By default it is in the right corner of the window.
Just create a layout with buttons in the middle and set it as the content of ConfirmDialog. You can get the buttons using ConfirmDialog.get...Button(). Example:
ConfirmDialog cd = ConfirmDialog.getFactory().create("Title", "", "OK",
"Cancel");
cd.setHeight("400px");
cd.setWidth("400px");
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(cd.getCancelButton());
buttons.addComponent(cd.getOkButton());
VerticalLayout content = new VerticalLayout(buttons);
content.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
content.setSizeFull();
cd.setContent(content);
cd.show(this, null, false);
However I agree with Jan that the good practice is having them in the bottom right corner.
Keeping the buttons in the right lower corner is good practice when it comes to usability. Have a look at http://uxmovement.com/buttons/why-ok-buttons-in-dialog-boxes-work-best-on-the-right/ for more details. I would advice not to sacrifice behavior conventions for personal taste.