Reputation: 3319
the model class has a property visible, it's string can have two values "1" means yes, "0" means no, how can I bind it to a checkbox ?
Upvotes: 2
Views: 2330
Reputation: 1324757
I would recommend using the JFace data binding framework: see Vogella's tutorial on it.
JFace Data Binding is a framework which connects properties of objects.
For example you would bind the property "firstName" of a "Person"" object to a text field in the UI. This binding would synchronize changes in the model and the UI, e.g. if the user changes the name in the UI the model would automatically be updated
With:
public class Person implements PropertyChangeListener {
[...]
private String gender;
And:
DataBindingContext ctx = new DataBindingContext();
widgetValue = WidgetProperties.selection().observe(marriedButton);
modelValue = BeanProperties.value(Person.class, "married").observe(person);
ctx.bindValue(widgetValue, modelValue);
Upvotes: 7