I have the rare use case, where the swing-view lives longer than the related presentation-model: The swing-view lives as long as the application lives, the presentation-model is replaced each time a new "run" is started in the application.
The presentation-model is a groovy bean:
@Bindable
static class MyPresentationModel{
String myText = 'default-text'
}
The swing-view is a JTextField, bound using a JGoodies BeanAdapter:
JTextField myTextField = new JTextField()
MyPresentationModel pm = new MyPresentationModel()
BeanAdapter<MyPresentationModel> beanAdapter = new BeanAdapter<MyPresentationModel>(pm, true)
Bindings.bind(myTextField , beanAdapter.getValueModel('myText'))
How can I unbind the presentation model from the JTextField afterwards?
The only thing in that direction I found in the JGoodies-Binding API is
beanAdapter.setBean(null)
But this doesn't - of course - remove the JGoodies-PropertyChangeListener and the JGoodies-DocumentListener from the JTextField. Is there a a nice way to remove those? Or do I have hack it down myself?