这是一个没有额外附加组件的工作示例。您可以使用水平和垂直布局。
public class TestUI extends UI {
Panel L = new Panel();
Panel C = new Panel();
Panel B = new Panel();
Panel R = new Panel();
Button bL = new Button("Toggle L", new CloseButtonHandler(L));
Button bC = new Button("Toggle C", new CloseButtonHandler(C));
Button bB = new Button("Toggle B", new CloseButtonHandler(B));
Button bR = new Button("Toggle R", new CloseButtonHandler(R));
@Override
protected void init(VaadinRequest request) {
L.setWidth("80px");
L.setHeight("100%");
L.setContent(new Label("L"));
R.setWidth("80px");
R.setHeight("100%");
R.setContent(new Label("R"));
B.setHeight("80px");
B.setWidth("100%");
B.setContent(new Label("B"));
C.setHeight("100%");
C.setHeight("100%");
C.setContent(new Label("C"));
VerticalLayout vl = new VerticalLayout();
vl.addComponent(C);
vl.addComponent(B);
vl.setExpandRatio(C, 1);
vl.setSizeFull();
HorizontalLayout hl = new HorizontalLayout();
hl.addComponent(L);
hl.addComponent(vl);
hl.addComponent(R);
hl.setExpandRatio(vl, 1);
hl.setSizeFull();
CssLayout root = new CssLayout();
root.addComponent(bL);
root.addComponent(bC);
root.addComponent(bB);
root.addComponent(bR);
root.addComponent(hl);
root.setSizeFull();
setContent(root);
}
private class CloseButtonHandler implements ClickListener {
private Panel layout;
public CloseButtonHandler(Panel layout) {
this.layout = layout;
}
@Override
public void buttonClick(ClickEvent event) {
layout.setVisible(!layout.isVisible());
}
}
}
该示例适用于 Vaadin 7,但该概念也适用于 Vaadin 6。