AWT入门 Frame篇

来源:互联网 发布:nginx 启动不了windows 编辑:程序博客网 时间:2024/05/22 08:22
import java.awt.*;public class TestMultiFrame {public static void main(String[] args) {SubFrame f1 = new SubFrame(100,100,200,200,Color.BLUE);SubFrame f2 = new SubFrame(300,100,200,200,Color.darkGray);SubFrame f3 = new SubFrame(100,300,200,200,Color.CYAN);SubFrame f4 = new SubFrame(300,300,200,200,Color.magenta);}}class SubFrame extends Frame{static int serial = 1;SubFrame(int x, int y, int height, int width, Color color){setTitle("SubFrame " + (serial++));//super("SubFrame " + (serial++)); 调用的Fram构造方法之一setBackground(color);setLayout(null);super.setVisible(true);super.setBounds(x, y, width, height);}}

0 0
原创粉丝点击