CS 121 Lecture Notes - Lecture 26: Layout Manager, Enter Key
Document Summary
A jbutton generates an action event when it is pushed: the listener class we write will be an action event listener, we define a class called buttonlistener to represent the listener for this event. The relationship between a listener & its gui is one of the few situations in which an inner class is appropriate. Listener classes are written by implementing an interface: a list of methods that the implementing class must define. The java standard class library contains interfaces for many types of events. An action listener is created by implementing the actionlistener interface: therefore, we include the implements clause in the buttonlistener class. The only method listed in the actionlistener interface is the actionperformed method, so that"s the only method that the. Text fields: ex: the fahrenheit program presents a gui that includes a text field into which the user can type a fahrenheit temperature.