learn more...A listener in Java is an object that is used to handle events. In effect, it is implemented to listen for events and then tell the program the required information about that event, which you may then handle. For example, if the player moves the mouse, a listener will alert the program that the mouse has been moved and give details of its position, relative to the component currently occupying that area of the screen. The most commonly used event listeners are shown below and are found in the package java.awt.event.
The following tables show details of the abstract methods defined in these three listeners and the events that invoke them. KeyListener
MouseListener
MouseMotionListener
For convenience, javax.swing.event.MouseInputListener implements all of the methods included in the MouseListener and MouseMotionListener interfaces together. Information about an event is stored in an event object, which is passed as a parameter to a listener method when it is invoked. This is shown in the previous tables, with the class KeyEvent for events associated with the keyboard and the class MouseEvent for events associated with the mouse. |
||||||||||||||||||||||||||||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |