Code Sample: Event Listeners (Anonymous Inner Classes) v1.0
October 2nd, 2008
In class tonight, we discussed a number of ways to implement the event listener interfaces that drive Swing. One such approach is through the use of anonymous inner classes.
Anonymous inner classes are called as such because they do not have a name. They are instantiated at the same time the class is defined. The code in this sample includes comments describing the syntax of how these types of inner classes are defined, so be sure to look at the source in addition to compiling and running the application.
Going forward, I’m going to post another sample of this application, ported to use named inner classes for the implementation instead of anonymous inner classes.
The attached code is released under the GNU General Public License.

