package com.kuang.lesson1;
import java.awt.*;
public class TestFame2 {
public static void main(String[] args) {
//展示多个窗口
MyFrame myFrame1=new MyFrame(100,100,200,200,Color.blue);
MyFrame myFrame2=new MyFrame(300,100,200,200,Color.yellow);
MyFrame myFrame3=new MyFrame(100,300,200,200,Color.red);
MyFrame myFrame4=new MyFrame(300,300,200,200,Color.MAGENTA);
}
}
class MyFrame extends Frame{
static int id=0;
//因为要实例化,所以要构造器,如下
public MyFrame(int x,int y,int w,int h,Color color){
super("My frame"+(++id));
setBounds(x, y, w, h);
setBackground(color);
setVisible(true);
}
}
![]()