0

Why there is an empty item added in the ComboBox? How to get only 2 items? No extra empty item.

ComboBox<GroupType> typeSelect = new ComboBox<>();
typeSelect.setId("portfolioGroupTypeSelect");
typeSelect.setItems(GroupType.PortfolioGroup, GroupType.DynamicGroup);
//  HasCaption.fillTo(typeSelect, GroupType.class); I tried it as well
typeSelect.addValueChangeListener(new TypeSelectValueChanged());

public enum GroupType implements HasCaption {
    PortfolioGroup("PortfolioGroupsWindow.typeSelect.portfolioGroup"),
    DynamicGroup("PortfolioGroupsWindow.typeSelect.dynamicGroup");
    private final String key;
    GroupType(String key) {
        this.key = key;
    }

    @Override
    public String getCaption() {
        return SalkkuTM.getI18N(key);
    }
}

enter image description here

masiboo
  • 4,537
  • 9
  • 75
  • 136

1 Answers1

1

I found the solutions as:-

typeSelect.setEmptySelectionAllowed(false);

It removes the empty item. I found it right after posting the question.

masiboo
  • 4,537
  • 9
  • 75
  • 136