0% found this document useful (0 votes)
42 views

Window Listener

notes advance java

Uploaded by

Prathamesh Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
42 views

Window Listener

notes advance java

Uploaded by

Prathamesh Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
ria, 12:11 PM Java Windowl stoner javatpoint © “Vg aay FT. Poctourborea ae reer eel Structures Intps:iiwwjavatpoin.comjava-windowlstoner 18 SCROLL TO Te ‘mgm, 12:1 PM ave Window stoner avatpint Java WindowListener Interface ‘The Java WindowListener is notified whenever you change the state of window. It is notified against Windowévent. The ‘WindowListener interface is found in java.awt.event package. It has three methods. WindowListener interface declaration The declaration for java.anteventWindowlistener interface is shown below: public interface WindowListener extends EventListener Methods of WindowListener interface ‘The signature of 7 methods found in WindowListener interface with their usage are given belo: Sr. Method signature Description 1 public abstract void windowActivated Its called when the Window is set to be an active Window. (WindowEvent e}; 2 public abstract. void windowClosed | Its called when a window has been closed as the result of calling (Windowvent e}; dispose on the window. 3 public abstract void windowClosing It is called when the user attempts to close the window from the (WindowEvent e}; system menu of the window. 4 public abstract void windowDeactivated Itis called when a Window is not an active Window anymore, (Windowvent e}; 5 public abstract void windowDeiconified | It is called when a window is changed from a minimized to a (Windowvent e}; normal state. 6 public abstract void windowleonified It is called when a window is changed from a normal to a (WindowEvent ey, minimized state 7. public abstract void windowOpened _ Its called when window is made visible for the first time, (WindowEvent e}; Methods inherited by the WindowListener ‘This interface inherits methods from the EventListener interface, Ro Intps:iiwwjavatpoin.comjava-windowlstoner 218 ria, 12:11 PM Java Windowl stone Javatpoin Working of WindowListener interface © Ifa class needs to process some Window events, an object should exist which can implement the interface, © As the object is already registered with Listener, an event will be generated on all the states of window, © This helps in generation of invocation of relevant method in listener's object. And then WindowEvent is passed after invocation, Java WindowListener Example In the following example, we are going to implement all the method of WindowListener interface one by one. WindowExample java {importing necessary libraries of awt Import javaaw." Import java.awteventWindowEvent; import java.awteventWindowlistener; // dass which inherits Frame class and implements WindowiListener interface public class WindowExample extends Frame implements WindowListener { 11 class constructor Windowxampled ( // adding Windoviistener to the frame addWindowListener(this) // setting the size, layout and visibility of frame setSize (400, 400); setLayout (null setVisible (true); ) // main method Public static void main(Stringl] args) ( new WindowExample(; Qo // overriding windowActivated) method of WindowListener interface which prints the Public void windowActvated (WindowEvent arg0) ( Intps:ihwwjavatpoin.comjava-windowlstoner 318 ria, 12:11 PM Java Windowl stoner javatpoint System.out.printin(-activated’); // overriding windowClosed() method of WindowListener interface which prints the given string when window is closed public void windowClosed (WindowEvent argO) ( ‘System.out printin(‘closed); 1/ overriding windowClosing®) method of WindowListener interface which prints the given string when we attempt to close wit public void windowClosing (WindowEvent arg0) { ‘System out printin(“closing’} disposed; 1/ overriding windowDeactivated) method of Windowlistener interface which prints the given string when window is not activ public void windowDeactivated (WindowEvent argQ) ( System.out printin('deactivated’); // overriding windowDeiconified) method of WindowListener interface which prints the given string when window is modified public void windowDeiconified (WindowEvent arg0) ‘System.out printin(‘deiconified"y; 11 overriding windowiconified() method of Windowlistener interface wiich prints the given string when window is modified fre public void windowiconified(WindowEvent argO) ( ‘System out printi(‘iconified"): 1/ overriding windowOpened() method of WindowListener interface which prints the given string when window is first opened public void windowOpened(WindowEvent arg0) ( System.out.printin('opened”); Output: Qo intps:ihwwjavatpoin.comijava-windowlstoner 48 srt9s, 12:11 PM Java Windowl stoner javatpoint ry : :Nbatch4we? javac WindowExample. java :\bat chdwe> java WindowExample activated \bat ch4we?_, Qo nips javatpoin.comijava-windowlstonor 58 srt9rs, 12:11 PM Java Windowlstener- javatpoint [2Youtube For Videos Join Our Youtube Channel: Join Now Feedback ‘© Send your Feedback to [email protected] Help Others, Please Share Learn Latest Tutorials Splunk tutorial SPSS tutorial Splunk spss React tutorial —_—_g!Regex tutorial ReactlS Regex 1% React Native gf Python Design ‘sori Patterns eat Native Python Dein ates Preparation HAptiude Logica ae Reasoning Reasoning Intps:wwjavatpoin.comijava-windowlstoner Project Oriented Approach Leen from the basics, Online Classes, Project orientec Aocr Ap Swagger APSOL tutorial —_pTumbe tutorial ‘worl “Transact-SQL ‘Tumble Swagger Reinforcement g2R Programming 42RxJS tutorial Teaming tutorial tutorial es Reinforcement Programming Leeming B Python Pillow ZL Python Turtle PKeras ustorial tutorial ‘tutorial ems Python Pillow Python Turtle Qo Leverbal Ability Verbal Ability Interview Questions Interview Questions 68 sia, 72:91 PM Trending Technologies Be Anica PAWS Tora Intligence saws Asif Ineligence WD Reacts. f, Data Science “Tutorial Tutorial, Reacts Data Science i Machine Tearing Tutorial Machine Learning B.Tech / MCA (DBMS tutorial DBMS PL Compiler Design tutorial Compiler Design iA Software Enginecring DevOps Tutorial Devops #Data Structures tutorial Dat Structures 2 Computer ‘Organization and “Architecture Computer Orpanization (eum tori Web Technology -ntpssiwwjavatpoin.comijava-windowlstonor & a Java Windowlstener- javatpoint Selenium ‘utorial Seleniam Angular 7 ‘Tutorial Angular 7 DAA tutorial DAA Discrete Mathematies Tutorial Diserete Mathematics Cyber Security tutorial Cloud (Computing Cloud Computing Operating System, Operating System Pthieal Hacking thica Hacking Automata Tutorial PHadoop tutorial Hadoop AGI Tutorial it Computer Network tutorial Computer Network Qo 8 ria, 12:11 PM Software gineering ACH tutorial (22dava tutorial oH Java Control Data Mining ‘Systems tutorial Tutorial Control System Data Mining nips javatpoin.comijava-windowlstonor Java Windowlstener- javatpoint cyber Security Automata Programming Net PP ython tutorial List of Framework Programs ora Python torial Programs Net Data Warehouse Tutorial Data Warehouse Qo 88

You might also like