package cn.lyc.listener;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class Test {
public static void main(String[] args){
Frame frame = new Frame("HELLO WORLD");//建立一个窗体
Panel panel = new Panel(null);//面板
frame.setLayout(null);//设置窗体的布局
frame.setBounds(300,300,500,500);//设置坐标
frame.setBackground(Color.red);//设置颜色
panel.setBounds(50,50,300,300);
panel.setBackground(Color.yellow);
frame.add(panel);
frame.setVisible(true);//可见
//监听事件,关闭事件
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}