Java attempts to mutate in notifications

I have two tables and a module they all look at

Basic – they should all update the module and update from it Is there a simple way to do it without binding the framework

I do (but I keep trying to mutate in notifications) –

Update about my textfield

myTextField.getDocument().addDocumentListener(new TFDocumentListener() {
            protected void userChangedTF() {
                Float value = myTextField.getValue();
                if (value != null) {
                    myObj.setMyAttribute(value);
                }
            }
        });

Still in UI – register changes

myObj.addMyAttributeChangedListener(new Valuechangelistener<Float>() {
            @Override public void valueChanged(Float value) {
                if (!myTextField.isFocusOwner()) {
                    myTextField.setValueIn(value);
                }
            }
        });

In the module – when setmyattribute occurs – it calls this function

private void notifyIntervalChanged(float newValue) {
    for (Valuechangelistener valuechangelistener : intervalChangedListenersList) {
        valuechangelistener.valueChanged(newValue);
    }
}

I announced

public interface Valuechangelistener<T> {
     void valueChanged(T Value)
}

Solution

If you need to change the contents of the same JTextComponent in the listener, in swingutilities Changes in invoker() (for example, settext())

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>