我有4个组件的水平布局:组合框,textField1,textField2和复选框。基于复选框textField2是否显示。当checkbox设置为false时,textField2不可见。如何防止textField1扩展?我希望组件的位置固定..如果没有显示复选框或textField2,页面中剩余的其他内容仍然看起来相同。因此,防止扩展到具有水平布局的组件的剩余空间。
答案 0 :(得分:0)
最简单的方法是将要隐藏的字段放在另一个具有固定大小且仍然可见的布局中。像这样:
VerticalLayout textField2Layout = new VerticalLayout(textField2);
textField2Layout.setWidth("200px");
VerticalLayout verticalLayout = new VerticalLayout(combobox,textField1,textField2Layout,checkbox);