3초기억력

GUI(awt) - Gridlayout 본문

자바_기초

GUI(awt) - Gridlayout

잠수콩 2019. 5. 27. 15:26
package GUI;

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class GridLayOutEx extends Frame{
	
	Button btn1 = new Button("1");
	Button btn2 = new Button("2");
	Button btn3 = new Button("3");
	Button btn4 = new Button("4");
	Button btn5 = new Button("5");
	Button btn6 = new Button("6");
	
	Panel pan = new Panel();
	
	
	public GridLayOutEx() {
		setSize(300,300);
		setVisible(true);
		
		setLayout(new GridLayout(3,2));
		
		add(btn1);  add(btn2);
		add(btn4);  add(btn3);		
		add(btn5);	add(btn6);
		
		
		//x누르면 창off
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});		
	}

	public static void main(String[] args) {
		
			new GridLayOutEx();
			
			//Gridlayout 
			// - 바둑판, 행과 열
			// - 동일한 크기로 정렬하는 레이아웃
			//  new Gridlayout(가로,세로)
			
			
			
	}
}




'자바_기초' 카테고리의 다른 글

접근제어자) public  (0) 2019.06.07
제어자)static  (0) 2019.06.07
GUI(awt) - Boarderlayout  (0) 2019.05.27
GUI(awt) - flowlayout  (0) 2019.05.27
형변환  (0) 2019.05.27
Comments