I have added an List box and and i have an list of value that needs to be populated in the list box. The only option i could find to add values to the list box is listbox.addItem... where i have to iterate the list of values i have and need to add it one by one. Is there any other way where i can 开发者_如何学Goadd the entire list in one single call.??
private final List<Operation> numberComparisons = Arrays.asList(Operation.EQUAL, Operation.GREATER_THAN, Operation.GREATER_THAN_OR_EQUAL, Operation.LESS_THAN, Operation.LESS_THAN_OR_EQUAL, Operation.FILLED_IN, Operation.EMPTY);
now i have to add this number comparisons list into
ListBox conditionDropDown = new ListBox();
conditionDropDown.addItem(numberComparisons);
..... how can i do this...???
Maybe try this:
class MyListBox extends ListBox {
public void addAsList(List<Operation> list) {
for (Operation operation : Operation.values()) {
addItem(operation.toString());
}
}
and finally:
MyListBox conditionDropDown = new MyListBox();
conditionDropDown.addAsList(numberComparisons);
Have a look at the ValueListBox widget; you'll then use a Renderer
to "generate" the String
representation of your Operation
(used to display them to the user in the list).
精彩评论