问题描述
我在 Vaadin 6 中做我的项目.在那里,我已将组件集成到网格布局中.我附上了一张图片.它类似于我的项目布局.它类似于日食.因此,布局将在左侧和右侧有两个侧面板.以及一个中心和底部面板.图像中的红色是按钮.当我按下它们时,面板将被最小化.我希望中心面板扩展并占据最小化面板的区域.我已将面板集成到网格布局中.谁能告诉我如何在网格布局中展开组件.
I am doing my project in Vaadin 6. In that, I have integrated the components in a Grid layout. I have attached a image with this. It resembles my Project layout. It is similar to eclipse. So, The layout will have two side panels on left and right. and a center and bottom panel.And the red color in the image are buttons. When I press them the panel will be minimized. I want the center panel to expand and occupy the minimized panel's area. I have integrated the panels in grid layout. Can anyone tell me how to expand a component in the grid layout.
当我最小化R"时;'C' &'B' 必须占据它的区域.
When I minimize 'R'; 'C' & 'B' have to occupy it's area.
当我最小化B"时;'C' 必须占据它的区域.
When I minimize 'B'; 'C' have to occupy it's area.
当我最小化L"时;'C' &'B' 必须占据它的区域.
When I minimize 'L'; 'C' & 'B' have to occupy it's area.
推荐答案
这是一个没有附加插件的工作示例.您可以使用水平和垂直布局.
Here a working example without additional add-on. You can use horizontal and vertical layout.
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.
The example is for Vaadin 7 but the concept should work with Vaadin 6 too.
这篇关于Vaadin - 在 Vaadin 的网格布局中展开组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!