Dev_Study/Java_backup

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

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

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

public class BorderLayoutEx extends JFrame {
	
	public BorderLayoutEx (){
		
		setLayout(new BorderLayout()); //프레임 배치관리자
		setTitle("BorderLayout 입니다");
		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");
		
		this.add(bt1, BorderLayout.CENTER);
		this.add(bt2, BorderLayout.NORTH);
		this.add(bt3, BorderLayout.SOUTH);
		this.add(bt4, BorderLayout.EAST);
		this.add(bt5, BorderLayout.WEST);
	}

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


반응형