Java NetBeans vinculante. cómo actualizar fijaciones ..?
Pregunta
tengo un JLabel y el uso de NetBeans i haberla asociado a una propiedad en el formulario.
el problema es cómo puedo actualizar los valores de unión cuando la propiedad de que el texto de la etiqueta se ha unido a ha cambiado. this.firePropertyChange funciona, pero huele mal ... Me gustaría someonething como this.bindingGroup.refresh o This.Refresh que actualizará el texto etiquetas
por ejemplo la jLabel.text está obligado a formar someValue
private someClass someThing;
public String getSomeValue(){
return someThing.getSomeThing();
}
//when someMethof is fired the jlabel should update its text value
public void someMethod(){
someThing = someThingElse;
bindingGroup.refresh()?????
}
Solución
Desafortunadamente, si desea utilizar las API de Frijoles de unión, tendrá que lidiar con el olor de firePropertyChange
.
Sin embargo, no veo cuál es el problema? Es un cambio bastante simple. Cambiar su clase a la siguiente:
private someClass someThing;
public String getSomeValue(){
return someThing.getSomeThing();
}
//when someMethof is fired the jlabel should update its text value
public void someMethod(){
someClass oldValue = someThing;
someThing = someThingElse;
this.firePropertyChange("someValue", oldValue, someThing);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow