AWT入門 Frame篇

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);
		
	}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章