The code changed by the window size.

xiaoxiao2021-03-06  56

When the size of the window changes, it does not trigger WindowStateChangeD but triggers the ComponentAdapter.

Import java.awt. *;

Import java.awt.event. *;

Import javax.swing. *;

Public class myframe extends jframe {

Class MCA EXTENDS Componentadapter {

Public Void ComponentResized (ComponEntevent E) {

System.out.println ("ComponentResized");

}

}

Class Mwa EXTENDS WINDOWADAPTER {

Public void windowClosing (WindowEvent E) {

System.exit (0);

}

Public void windowStateChanged (WindowEvent E) {

System.out.println ("WindowStateChanged");

}

}

Public myframe () {

Super ("Test");

AddWindowListener (New MWA ());

AddcomponentListener (New MCA ());

Setsize (200, 100);

SetVisible (TRUE);

}

Public static void main (String [] args) {

Myframe mf = new myframe ();

}

}

I have been in the old half a day, really depressed.

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

New Post(0)