How can I bind a property (e.g. an Enum) to a component property of a different type (e.g. an image for each Enum)?
Frage
I have inherited a project that uses JGoodies Binding to connect the domain model to the GUI. However, there are some inconsistencies that I have found which also cause some bugs.
In this concrete case, the GUI is represented by two radio buttons and a label. Depending on which button is selected, the label should display a certain image. The buttons are bound to different Enum values, like this:
AbstractValueModel enumSelectionModel = presentationModel.getModel("selection");
radioBtn1 = BasicComponentFactory.createRadioButton(enumSelectionModel,
Selection.selection1, "");
radioBtn2 = BasicComponentFactory.createRadioButton(enumSelectionModel,
Selection.selection2, "");
"selection"
is the bound property, and Selection
is the Enum, which means that when a different button is changed, the selection
property in my model is set to the corresponding Enum value.
My question is: How can I bind this property to the image displayed by the label?
From what I saw, JGoodies is excellent for binding things like strings to text fields, but in this case, there should also be a transformation, some logic which decides maps the enum property to the image.
Keine korrekte Lösung