First, you learn how to connect the event-producing text fields and buttons to listeners that maintain the form's instance variables.
In particular, you need to know that both text fields and buttons
activate connected action-event listeners, to which they supply
action events, which are instances of the ActionEvent
class.
Action-event listeners implement the ActionListener
interface, which
requires the definition of the actionPerformed
method; that
actionPerformed
method is called when the connected view activates
an action-event listener.
Text fields activate connected action-event listeners when you press Enter or click on another component; buttons produce action events when you click on them.