本帖最后由 工善器 于 2013-10-23 21:09 编辑
package en.itcast.java.tools;
import java.awt.*;
import java.awt.Event.*;
import java.awt.event.WindowAdapter;
import javax.swing.*;
public class awt {
public static void main(String[] args) {
Frame f=new Frame("new frame");
f.setSize(400,300);
f.setLocation(300,200);
f.setLayout(new FlowLayout());
//说明是流式布局
Button b=new Button();
f.add(b);
f.addWindowListener(
new WindowAdapter{
public void windowClosing(Window e)
{
System.out.println("我关了");
}
public void widnowActived(Window e)
{
System.out.println("我急活了");
}
public void windowOpen(Window e)
{
System.out.println("我打开了");
}
});
f.setVisible(true);
}
}
|