Can you describe what exactly you want to achieve? Looks like too much code to deal only with two genders In any case, I’ll share some ideas that might help. I would define an enum like the following:
public enum Gender { FEMALE, MALE }
And then just add the options to the ComboBox like this:
ComboBox gender = new ComboBox();
gender.addItems(Gender.values());
And if you want to set a “default value” you can do:
gender.setValue(Gender.FEMALE);
Also, if you have a domain class like this:
[font=courier new]
public static class Person {
…
private Gender gender;
... getters and setters ...
}
[/font]
You can bind to a particular instance using the
BeanFieldGroup.bindFieldsUnbuffered static method.
But I don’t understand well your use case particularly the TextField and its change listener.
I did that because my country using ID card number that contain number of male or female in noid_textfield. So that’s why i used TextField with change Listener. From the number of TextField it wll load combobox Gender with a default value that set from listener textfied ID without removing the gender name list.
Above codes its just example that will help me as a based.
I would like result like below. which default value is male which get from last number from textfield, if even is for Male, uneven is for Female:
If you can give me how to set default value to Combobox using FieldGroup bind, its really awesome to me.
a) I using Iterator the combobox by defining into Bean GenderTable.
b) I compare the code Gender from value in combobox_gender with method getGender() which will returning of code gender.