//TestFrame.java
import java.awt.*;

public class TestFrame{
	public static void main(String[] args){
		Frame f=new Frame("My First Test !");
		f.setLocation(500,100);
		f.setSize(500,500);
		f.setBackground(Color.darkGray);
		f.setResizable(false);
		f.setVisible(true);	
	}
}



//TestMultiFrame.java
import java.awt.*;

public class TestMulitFrame{
	public static void main(String[] args){
		new MyFrame(100,100,100,100,Color.yellow);
		new MyFrame(100,200,100,100,Color.green);
		new MyFrame(200,100,100,100,Color.blue);
		new MyFrame(200,200,100,100,Color.red);
	}
}

class MyFrame extends Frame{
		static int id=0;
		MyFrame(int x,int y,int w,int h,Color color){
			super("Frame : "+ (id++));
			setBackground(color);
			setLayout(null);
			setBounds(x,y,w,h);
			setVisible(true);	
		}	
}
//TestPanel.java

import java.awt.*;

public class TestPanel{
	public static void main(String[] args){
		Frame f=new Frame("Java Frame with Panle");
		Panel p=new Panel(null);
		f.setLayout(null);
		f.setBounds(300,300,500,500);
		f.setBackground(Color.white);
		p.setBounds(50,50,400,400);
		p.setBackground(Color.red);
		f.add(p);
		f.setVisible(true);
	}
}



//TestMultiPanel.java
import java.awt.*;

public class TestMultPanel{
	public static void main(String[] args){
		new MyFrame2("Hello",300,300,400,400);
	}
}

class MyFrame2 extends Frame{
	private Panel p1,p2,p3,p4;
	MyFrame2(String s,int x,int y,int w,int h){
		super(s);	
		p1=new Panel(null);
		p2=new Panel(null);
		p3=new Panel(null);
		p4=new Panel(null);
		p1.setBounds(0,0,w/2,h/2);
		p2.setBounds(0,h/2,w/2,h/2);
		p3.setBounds(w/2,0,w/2,h/2);
		p4.setBounds(w/2,h/2,w/2,h/2);
		p1.setBackground(Color.BLUE);
		p2.setBackground(Color.GREEN);
		p3.setBackground(Color.RED);
		p4.setBackground(Color.GRAY);
		add(p1);
		add(p2);
		add(p3);
		add(p4);
		setBounds(x,y,w,h);
		setVisible(true);
	}	
}



//CenterPanel.java
import java.awt.*;

public class CenterPanel{
	public static void main(String[] args){
		new MyFrame("Hello",300,300,400,400);
	}
}

class MyFrame extends Frame{
	MyFrame(String s,int x,int y,int w,int h){
		super(s);
		setLayout(null);	
		setBackground(Color.RED);
		setBounds(x,y,w,h);
		Panel p=new Panel(null);
		p.setBounds(w/4,h/4,w/2,h/2);
		p.setBackground(Color.YELLOW);
		add(p);
		setVisible(true);
	}	
}



//TestGridLayout.java
import java.awt.*;

public class TestGridLayout{
	public static void main(String[] args){
		Frame f=new Frame("GridLayout");
		Button b1=new Button("1");
		Button b2=new Button("2");
		Button b3=new Button("3");
		Button b4=new Button("4");
		Button b5=new Button("5");
		Button b6=new Button("6");
		
		f.setLayout(new GridLayout(3,2));
		
		f.add(b1);
		f.add(b2);
		f.add(b3);
		f.add(b4);
		f.add(b5);
		f.add(b6);
		
		f.pack();
		
		f.setVisible(true);
	}
}



//TestFlowLayout.java

import java.awt.*;

public class TestFlowLayout2{
	public static void main(String[] args){
		Frame f=new Frame("FlowLayout");
		FlowLayout l=new FlowLayout(FlowLayout.CENTER,20,40);
		f.setLayout(l);
		for(int i=0;i<10;i++){
			f.add(new Button("Button " + i));	
		}
		f.setVisible(true);
	}
}



//TestBorderLayout.java

import java.awt.*;

public class TestBorderLayout{
	public static void main(String[] args){
		Frame f=new Frame("BorderLayout");
		Button N=new Button("北");
		Button S=new Button("南");
		Button W=new Button("西");
		Button E=new Button("东");
		Button C=new Button("中");
		
		f.add(N,"North");
		f.add(S,"South");
		f.add(W,"West");
		f.add(E,"East");
		f.add(C,"Center");
		
		
		/*f.add(N,BorderLayout.NORTH);
		f.add(S,BorderLayout.SOUTH);
		f.add(W,BorderLayout.WEST);
		f.add(E,BorderLayout.EAST);
		f.add(C,BorderLayout.CENTER);*/
		f.setSize(200,200);
		f.setVisible(true);
	}
}