sape
23 Jun 2009, 4:31 AM
Does anybody know how you could create a ComboBox using an Java enum?
If I try something like this the factory is not created and the code will result in a NullPointerException:
factory = BeanModelLookup.get().getFactory(TarrifType.class);
store = tarrifType.getStore();
final TarrifType[] tarrifTypes = TarrifType.values();
for (TarrifType type : tarrifTypes) {
final BeanModel beanModel = factory.createModel(type);
store.add(beanModel);
}
If I try something like this I get a ClassCastException :(:
final SimpleComboBox<NumberType> numberType = new SimpleComboBox<NumberType>();
final NumberType[] values = NumberType.values();
for (NumberType type : values) {
numberType.add(type);
}
Does anybody know if it's possible to use the binding functionality with Java enums?
Thanks in advance and I hope someone could help me out.
If I try something like this the factory is not created and the code will result in a NullPointerException:
factory = BeanModelLookup.get().getFactory(TarrifType.class);
store = tarrifType.getStore();
final TarrifType[] tarrifTypes = TarrifType.values();
for (TarrifType type : tarrifTypes) {
final BeanModel beanModel = factory.createModel(type);
store.add(beanModel);
}
If I try something like this I get a ClassCastException :(:
final SimpleComboBox<NumberType> numberType = new SimpleComboBox<NumberType>();
final NumberType[] values = NumberType.values();
for (NumberType type : values) {
numberType.add(type);
}
Does anybody know if it's possible to use the binding functionality with Java enums?
Thanks in advance and I hope someone could help me out.