package strive.awt_1;
import java.awt.Cursor;
import java.awt.Frame;
public class FrameTest_1 {
@SuppressWarnings("depreca tion")
public static void main(String[] args) {
WinUntil close = new WinUntil();
Frame frame = new Frame();
frame.addWindowListener(close);
//设置窗体高宽位置
frame.setBounds(600, 100, 600, 600);
//名称
frame.setTitle("Windowss");
//设置背景色
frame.setBackground(Color.red);
//设置光标
frame.setCursor(Cursor.HAND_CURSOR);
//显示窗体
frame.setVisible(true);
}
}
package strive.awt_1;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
/**
* 窗体工具类
* @author Administrator
*/
public class WinUntil implements WindowListener {
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
//关闭窗体
System.exit(0);
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
}
在myEclipse点击启动