![]() |
The Abstract Window Toolkit (AWT) of Java provides a collection of graphical user interface (GUI) components for creating desktop applications. When it comes to managing window-related events, the WindowListener interface is used. The WindowListener interface provides methods for responding to window-related events such as opening, closing, activating or deactivating, and more such methods. WindowListener in AWTThe WindowListener interface in Java AWT is imported from the java.awt.event package. It is the basic connection or a link between your application and the window’s actions. By implementing this interface and overriding its methods in your class, you can respond to a wide range of window events. Syntax of WindowListener:public interface WindowListener extends EventListener The WindowListener interface in Java is declared with the above statement. It extends the EventListener interface which indicates that it helps in capturing and reacting to different window events in Java applications. WindowListener Interface MethodsGiven below are the abstract methods of the WindowListener interface.
Example of Java WindowListenerGiven below is a simple example to demonstrate the working of the WindowListener interface. Java
Use below commands to run the program, javac Window.java java Window Output of the above code in GIF:Explanation of the example:
Applications of the WindowListener InterfaceThere are many use cases of WindowListener interface, which we can use in our Java application to perform different actions.
|
Reffered: https://www.geeksforgeeks.org
Advance Java |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |