When an action is performed in a JAVA GUI, an event is sent to the JAVA program to let it know that something happened. This style of programming is known as event-driven programming. The user interacts with a GUI component, the program is notified of the event and the program processes the event. The user's interaction with the GUI drives the program. The methods that are called when an event occurs are also known as event handling methods. When a GUI event occurs in a program, JAVA creates an object containing information about the event that occurred and automatically calls an appropriate event handling method. Before any event can be processed, each GUI component must know which object in the program defines the event handling method that will be called when an event occurs.
The method actionPeroformed is one of several methods that process interactions between the user and GUI components. The first line of the method
public void actionPerformed (ActionEvent e)
indicates that actionPerformed is a public method that returns nothing when it completes its task. Method actionPerformed receives one argument - an ActionEvent - when it is called automatically in response to an action performed on a GUI component by the user. The ActionEvent argument contains information about the action that occurred.
Interfaces are implemented. Implementing an interface is like signing a contract with the compiler that states "I will define all the methods specified by the interface".
An interface is typically used in place of an abstract class when there is no default implementation to inherit - i.e., no instance variables, and no default method implementations.
To implement more than one interface, simply provide comma-separated list of interface names after the keyword implements in the class definition.