Before, learned inheritance, that is, the subclass inherits the parent class, the parent class refers to a relatively general class, and the subclass is more materialized, there are more methods of the class, and when all the methods in the parent class do not have a concrete method body, this class is called the interface. The key to defining an interface is "interface", which is the "public interface Interface name", and the property in the interface defaults to the "public static final data type constant name = value;" And the method in the interface is the "public" without the method body. Abstract the return value type abstracts the method name (data type parameter name); ", what is special is that the attribute in the interface must be a public static constant, the method must be a public abstract method, and because it is an abstract method, there is no construction method, cannot instantiate the object! The interface provides public, static, final, and abstract keywords by default, so it can be written without writing. Then you can define a class to implement (Inherit) the interface, the format is "public class class name Impilements interface Name {Implement all abstract methods in the interface}", must implement all the abstract methods, because the interface method default public, Therefore, the implementation must be added to public.
Development interface, first we want to create a form, and then add a variety of element components on this form, you can develop a simple interface. To create a form, give the form a name, then set the size, place the form to appear, add a desktop layout, manage the location of each element component, add a close program, and finally the most important thing is to set the form visible. In this way, it is a simple interface. When we do some work on the form, these actions are called events, and if we want to see events happening, we can add event listeners to the interface. In Java, each event corresponds to an event listener, which is defined in the Java.awt.event package. To understand an event, you must first locate the event source and locate the event source to add a monitor to the event source. What can be called an event source? All container components and element components can be called event sources. How do you determine who is the source of the event? Which component the mouse or keyboard action occurs on, and that component is the source of the event. Listen for any action on the event source, and if so, collect the information and give it to the object of the event interface for processing. The event interface is where the final operation is implemented. The approximate approach is to create the form first, and then add an event listener to the component that you want the event to occur. Then create a class to handle the event source event, presumably this is the step, the specific more read and write to know.
Interfaces and event mechanisms