You may have forgotten to register a listener with the button. Without a listener, the events are being ignored.
JTextField
A JTextField
is a box that contains text.
The user can type text into the box and the program can get it
and then use it as data.
The program can write the results of a calculation to a JTextField
.
Here is a Javascript text field (not a Swing text field, but close):
To enter text into the field you must first click the mouse pointer inside of it. This gives the field the keyboard focus (usually just called focus). When a component has the focus characters from the keyboard are directed to that component. A component gets focus by various means. The user might click it, or the program might give it focus.
Enter some text. Edit it using back space and delete. Copy some text from the web page and paste it into the field. All this works. But the field is not connected to any application code so nothing is done with the text. (The above was done with JavaScript, but Java works about the same).