How can I link a variable and a text box in the simplest possible way?
I.e. If the user changes the text box contents the variable changes and if the program changes the variable the text in the text box changes.
N.B. I’m using the swing and awt libraries.
Thanks in advance.
put your variable in an Observable wrapper. It will tell the JTextfield about the changes.
add a DocumentListener to the field.getDocument() to tell your variable that its value should change.