Dev_Study/Java_backup

[JAVA / SWING] 배치관리자(Layout Manager) - GridLayout

LeeDaniel 2016. 10. 7. 05:10
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class GridLayoutEx extends JFrame {
	
	public GridLayoutEx (){
		
		setLayout(new GridLayout(0, 4)); //GridLayout(행, 열)
		setTitle("GridLayout 입니다");
		setSize(300, 300);
		setLocationRelativeTo(null); //화면 중앙에 생성
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		
		JButton bt1 = new JButton("버튼1");
		JButton bt2 = new JButton("버튼2");
		JButton bt3 = new JButton("버튼3");
		JButton bt4 = new JButton("버튼4");
		JButton bt5 = new JButton("버튼5");
		JButton bt6 = new JButton("버튼6");
		JButton bt7 = new JButton("버튼7");
		JButton bt8 = new JButton("버튼8");
		JButton bt9 = new JButton("버튼9");
		
		this.add(bt1);
		this.add(bt2);
		this.add(bt3);
		this.add(bt4);
		this.add(bt5);
		this.add(bt6);
		this.add(bt7);
		this.add(bt8);
		this.add(bt9);
		
	}

	public static void main(String[] args) {
		GridLayoutEx e = new GridLayoutEx();
	}
	
}


반응형