About the window of the window

zhaozj2021-02-08  237

Javaduke original in www.dukejava.com ---- Java online home

About the window of the window

Choose supports pop-up windows, but pay attention to the following points in your application:

1) Definition of the window: Final frame userinfo = new frame ("New World Record"); Final is required, indicating constant value

2) How to join other components in the window:

Userinfo.setLayout (New flowLayout ());

UserInfo.add (New Label ("Hello");

UserInfo.add (New TextField (20));

Userinfo.add (New Button ("Save Button");

Basically, the same is added to the applet.

3) About the processing of the window event:

Userinfo.addwindowlistener (new windowadapter () {

Public void windowClosing (WindowEvent E) {

UserInfo.dispose ();}});

This is a standard handling window to turn off the function. In most windows that only need to handle the closing function, the code is simple, and of course, if you need to handle each function, it is best to handle the keyboard event in the previous example. This example covers other processing functions through a Windowadapter, pay attention to this compile generation, * $ 1.class, don't forget when the code is packaged.

4) About the display of the window:

Userinfo.setsize (200, 120); // Define the size

Userinfo.setVisible (TRUE); // Display

5) Operation in the applet:

When using the window, be sure to overwrite

Public void destroy () {

.........

Userinfo.dispose (); // In the applet, the Frame is eliminated after the page exits.

........ /

}

This is important: preventing the Frame resource waste after the page is launched. Unable to close.

转载请注明原文地址:https://www.9cbs.com/read-1734.html

New Post(0)