Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
Panel in center of Web-page
Hello all, i`m hust trying to make panel component display in the center of web page, but panel displayed in the left top corner of window. How can i decide it? Thanks a lot
GridLayout gl = new GridLayout();
Panel aPanel = new Panel("Hello world");
HorizontalLayout hl = new HorizontalLayout();
aPanel.setContent(hl);
hl.addComponents(new TextField("Login"), new TextField("Password"), new Button("Register"));
gl.addComponent(aPanel);
gl.setComponentAlignment(aPanel, Alignment.MIDDLE_CENTER);
setContent(gl)
Last updated on
Something like this does the trick:
VerticalLayout root = new VerticalLayout():
root.setSizeFull();
root.addComponent(yourPanel);
root.setComponentAlignment(yourPanel, Alignment.MIDDLE_CENTER);
Last updated on
+1
You cannot reply to this thread.