Java window listening

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.