Java window listening
It can be used in window (and subclass frame, jframe, jwindow)AddwindowlistenerMethod to addWindowlistener.
Monitors all window events.
Public interface windowlistener extendsEventlistener
Windowlistener is the listener interface used to receive window events.
The class to process window events either implements this interface (and all the methods it contains) or extends the abstract class windowadapter (only override the required methods ).
Then, use the addwindowlistener method of the window to register the listener object created from the class with the window.
When the window status is changed by opening, closing, activating, or disabling, icons, or canceling icons, the method in the listener object is called, and pass the receivwevent to this method.
Method Summary
Void windowactivated (receivwevent E)
It is called when window is set to an active window.
Void windowclosed (windowevent E)
It is called when the window is closed because of the call of dispose.
Void windowclosing (windowevent E)
It is called when a user tries to close the window from the system menu of the window.
Void windowdeactivated (receivwevent E)
Called when the window is no longer an active window.
Void windowdeiconified (invalid wevent E)
It is called when the window changes from the minimized state to the normal state.
Void authentication wiconified (invalid wevent E)
It is called when the window changes from normal to minimized.
Void windowopened (appswevent E)
Called when the window changes to visible for the first time.
Note: windowclosed is called only when it is disabled by dispose.. The function is not called even if you click the close button to close the program..
You can use addwindowstatelistener in window (and subclass frame, jframe, jwindow) to add windowstatelistener.
Monitors the status of all windows.
Public interface windowstatelistener extends eventlistenerwindowstatelistener is the listener interface used to receive window status events.
The class to process window state events either implements this interface (and all the methods it contains) or extends the abstract windowadapter class (only override the required methods ).
Then, use the addwindowstatelistener method of window to register the listener object created from this class with the window.
When the window status is changed by means of icons or maximization, The windowstatechanged method in the listener object is called and the receivwevent is passed to the method.
Method Summary
Void windowstatechanged (invalid wevent E)
Called when the window status changes.
Jframe is different from frame. When a user tries to close a window,Jframe knows how to respond.
When the user closes the window, the default behavior is simply hidden.Jframe. To change the default behavior, call setdefaclocloseoperation (INT ).
To make jframe behave the same as the frame instance, use setdefaultcloseoperation (windowconstants. do_nothing_on_close ).
If you want to click the close button to exit the program, callSetdefaclocloseoperation (jframe. exit_on_close );