我在表单布局中使用原生选择,如下所示:
您可以看到我的原生选择内容过于冗长:
accountType = new NativeSelect("Account Type:");
accountType.setRequired(true);
accountType.setNullSelectionItemId("--Select--");
accountType.addItem("Regular Savings");
accountType.addItem("Silver Savings");
accountType.addItem("Gold Privilege");
accountType.addItem("Advantage Premium Savings");
idProof = new NativeSelect("ID Proof:");
idProof.setSizeFull();
idProof.setRequired(true);
idProof.setNullSelectionItemId("--Select--");
idProof.addItem("Arms License issued by State/Central Government authorities");
idProof.addItem("Bank Pass Book with photograph issued or its susidiaries or Nationalised Banks");
FormLayout fLayout = new FormLayout(accountType,idProof);
然后我将此formlayout添加到horizontalLayout
HorizontalLayout hlayout = new HorizontalLayout(fLayout,fLayout2);
但我的idProof下拉单元格内容扩展了父级的宽度 如何强制下拉列表保留在父布局内,无论内容宽度是什么?
答案 0 :(得分:0)
idProof.setWidth(20, Unit.EM);
当然,你可以选择你想要的任何宽度,而且,不再需要idProof.setSizeFull()。