List of usage examples for com.vaadin.ui NativeSelect setItems
@Override public default void setItems(Collection<T> items)
From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java
License:Apache License
private NativeSelect<Color> createPrimaryColorSelect() { List<Color> colors = Arrays.asList(Color.BLACK, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW); NativeSelect<Color> fgColor = new NativeSelect<Color>("Primary color"); fgColor.setWidth("100px"); fgColor.setItemCaptionGenerator(color -> { switch (colors.indexOf(color)) { case 0:/* ww w . j a v a2 s . c om*/ return "Black"; case 1: return "Red"; case 2: return "Green"; case 3: return "Blue"; case 4: return "Yellow"; } return "Black"; }); fgColor.setItems(colors); fgColor.setValue(Color.BLACK); fgColor.addValueChangeListener(e -> code.setPrimaryColor(e.getValue())); return fgColor; }
From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java
License:Apache License
private NativeSelect<Color> createSecondaryColorSelect() { List<Color> colors = Arrays.asList(Color.WHITE, new Color(255, 0, 0, 50), new Color(0, 255, 0, 50), new Color(0, 0, 255, 50), new Color(255, 255, 0, 50)); final NativeSelect<Color> bgColor = new NativeSelect<Color>("Secondary color"); bgColor.setWidth("100px"); bgColor.setItemCaptionGenerator(color -> { switch (colors.indexOf(color)) { case 0:// w ww .j a v a2 s. c o m return "White"; case 1: return "Red"; case 2: return "Green"; case 3: return "Blue"; case 4: return "Yellow"; } return "White"; }); bgColor.setItems(colors); bgColor.setValue(Color.WHITE); bgColor.addValueChangeListener(e -> code.setSecondaryColor(e.getValue())); return bgColor; }