12th Chapter (GUI event)
1, the processing mechanism of GUI event is the key technology of building interactive application, in which the event is a variety of operations used in the program interface.
2, when writing the program for some of swing space such as JProgressBar, JTextField and other space in the global declaration after the use of the time must be new, I often forget (due to Java understanding not deep)
Private JTextField textField2;
TextField2 = new JTextField ();
3. Events are also an object in the Java language
4, after the listener receives the event, will delegate the specified method to perform the event processing, the listener inside the method sometimes we only use a small part of it or even individual methods, the other way undoubtedly to the code writing work increased burden, and added useless code, reading complexity also increased, The best way to solve the problem is the adapter.
5, because the adapter provides an empty method implementation of the listener interface, instantiating the adapter's instance object does not make any sense, so the adapter is defined as an abstract extraction star class, but the event methods are not abstract. This allows you to selectively override the specified method (the abstract class must override all abstract methods in the abstract class after it has been inherited) (after graduating a year today only to know the adapter is the origin of ah .... The adapter is an implementation class for the event listener interface.
6. The mouse event listener is defined by the MouseListener interface and the Mousemotionlistener interface
This article from "AutoComplete" blog, reproduced please contact the author!