public ListBoxDiscrete(ImageResource up, ImageResource down) { this.up = up; this.down = down; img = new ImageButton(down, "Select..."); HorizontalPanel panel = new HorizontalPanel(); panel.add(label); panel.add(img); initWidget(panel); setStylePrimaryName("SelectButton"); img.addClickHandler(this); label.addClickHandler(this); listTable.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (popup != null) popup.hide(); label.setText(texts.get(listTable.getSelected())); } }); }
public void setSelected(T selected) { label.setText(texts.get(selected)); listTable.setSelected(selected); }
public T getSelected() { return listTable.getSelected(); }
public void addChangeHandler(ChangeHandler handler) { listTable.addChangeHandler(handler); }
public void addItem(String text, T object) { texts.put(object, text); listTable.addItem(text, object); }