Hi,
I have problems with dialog box - how can I position TextArea component as center resizable component that will take full size, except the button below? Thank you.
Regards,
Matic
My code :
public class PackageHistoryDialog extends Window {
public PackageHistoryDialog() {
setModal(true);
setClosable(true);
setResizable(true);
setWidth(“700px”);
setHeight(“300px”);
VerticalLayout vl = new VerticalLayout();
TextArea ta = new TextArea();
ta.setReadOnly(true);
ta.setSizeFull();
vl.addComponent(ta);
vl.setSizeFull();
vl.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
Button closeB = new Button("Close", e -> close());
vl.addComponent(closeB);
vl.setComponentAlignment(closeB, Alignment.BOTTOM_RIGHT);
setContent(vl);
Easy: you need the VerticalLayout to have a full size to fill the Window in; then you need to expand the TextArea so that it will take up all available space in the parent VerticalLayout, pushing the Button down:
public class PackageHistoryDialog extends Window {
public PackageHistoryDialog() {
setModal(true);
setClosable(true);
setResizable(true);
setWidth("700px");
setHeight("300px");
VerticalLayout vl = new VerticalLayout();
TextArea ta = new TextArea();
ta.setReadOnly(true);
ta.setSizeFull();
vl.addComponent(ta);
vl.setExpandRatio(ta, 1f);
vl.setSizeFull();
vl.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
Button closeB = new Button("Close", e -> close());
vl.addComponent(closeB);
vl.setComponentAlignment(closeB, Alignment.BOTTOM_RIGHT);
setContent(vl);
}
}