AWT



package
aaaaa;

import java
.awt.*;

 

public class text2 {

 

    public static void main(String[] args) {

        

        Frame f=new Frame("我的窗体!") ;

        f.setSize(400,300);

        f.setLocation(300,200);

        f.setVisible(true);

    }

 

}


package aaaaa;

import java.awt.*;

import java.awt.event.*;

public class text1 {

    public

static void main(String[] args) {

    Frame

f=new Frame(“我的窗体!”) ;

    f.setSize(400,300);

    f.setLocation(300,200);

    f.setVisible(true);

    MyWindowListener

mw=new MyWindowListener();

    f.addWindowListener(mw);

    class

MyWindowListener implements WindowListener{

    public

void windowClosing(WindowEvent e){

    Window

window=e.getWindow();

    window.setVisible(false);

    window.dispose();

    }

    public

void windowActivated (WindowEvent e){

    }

    public

void windowClosed (WindowEvent e){

    }

    public

void windowDeactivated (WindowEvent e){

    }

    public

void windowDeiconified (WindowEvent e){

    }

    public

void windowIconified (WindowEvent e){

    }

    public

void windowOpened (WindowEvent e){

    }

    }

    }


package
aaaaa;

import
java.awt.*;

import
java.awt.event.*;

public class text3 {

 

    public static void main(String[] args) {

        Frame f=new Frame("我的窗体!") ;

        f.setSize(400,300);

        f.setLocation(300,200);

        f.setVisible(true);

        f.addWindowListener(new MyWindowListener());

    }

}

class
MyWindowListener extends WindowAdapter{ 

    public void windowClosing(WindowEvent e){

    Window window=(Window)e.getComponent();

        window.dispose();

        

    }

 

}

 

 

在这里插入代码片


猜你喜欢

转载自blog.csdn.net/weixin_43551399/article/details/84328442
AWT