2013년 7월 3일 수요일

(130703) 8일차 GridLayoutTest.java (GridLayout 테스트)

 - 소스
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JButton;

public class GridLayoutTest extends JFrame {

JButton northbutton, southbutton, eastbutton, westbutton, centerbutton;

public GridLayoutTest(){

// 닫기 버튼을 누르면 메모리에서 해제
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// 객체 생성
northbutton = new JButton("북쪽");
southbutton = new JButton("남쪽");
eastbutton = new JButton("동쪽");
westbutton = new JButton("서쪽");
centerbutton = new JButton("중앙");

this.setLayout(new GridLayout(3, 2));

this.add(northbutton);
this.add(southbutton);
this.add(eastbutton);
this.add(westbutton);
this.add(centerbutton);

this.setTitle("Hello");
this.setSize(400, 300);
this.setVisible(true);
}

public static void main(String[] args) {
new GridLayoutTest();
}
}


 - 결과