@Override protected void setup() { final ComboBox<String> box = new ComboBox(); box.setItems("Value 1", "Value 2", "Value 3", "Value 4"); box.setPrimaryStyleName("my-combobox"); addComponent(box); addComponent( new Button("Set primary style", event -> box.setPrimaryStyleName("my-second-combobox"))); }
@Override protected void setup() { Button b = new Button("Swap data provider"); b.addClickListener( event -> { if (biggerData) { combo.setItems("Item 3"); } else { combo.setItems("Item 1", "Item 2", "Item 3", "Item 4"); } biggerData = !biggerData; }); combo = new ComboBox<>(); combo.setItems("Item 1", "Item 2", "Item 3", "Item 4"); combo.addValueChangeListener(event -> log.log("Value is now: " + combo.getValue())); addComponent(log); addComponent(b); addComponent(combo); addComponent(new Button("Dummy for TestBench")); }