日期:2014-05-20 浏览次数:20849 次
//:TestFrame.java
import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame {
static int num;//存储窗口大小
TestFrame() {
super("Test "+(++num));//这里字符串"Test "中Test后加了一个空格,这只是为了测试,可以把这个空格删去。
//setBounds()的第3个、第4个参数是为了调节窗后的大小,把第3个数设置得稍大些,这样才能够看清楚标题。
this.setBounds(300,300,240,50);
this.setVisible(true);//这一句最好放在setBounds的后面
//this.setSize(300,200);
//this.setLocation(240,100);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) {
int nums=0;//存储窗口的个数
try{
if(args!=null){
nums=Integer.parseInt(args[0]);
}
}catch(Exception e){
System.err.println("请在参数中输入窗口的个数(int型):");
}
for(int i=1;i<=nums;i++){
new TestFrame();
}
}
}