package CHAPTER10;

import javax.swing.*;
import java.awt.*;

// JFrame을 상속하여 GUI 생성
public class C10_09_GridLayoutExample extends JFrame {
    public C10_09_GridLayoutExample() {
        // JFrame 기본 설정
        setTitle("GridLayout 예제");
        setSize(400, 400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // GridLayout 설정
        setLayout(new GridLayout(2, 4)); // 2행 4열

        // 버튼 추가
        add(new JButton("버튼 1"));
        add(new JButton("버튼 2"));
        add(new JButton("버튼 3"));
        add(new JButton("버튼 4"));
        add(new JButton("버튼 5"));
        add(new JButton("버튼 6"));
        add(new JButton("버튼 7"));
        add(new JButton("버튼 8"));
    }

    public static void main(String[] args) {
        // JFrame 실행
        GridLayoutExample frame = new GridLayoutExample();
        frame.setVisible(true);
    }
}

/**
 * 예제명: GridLayoutExample

설명:
GridLayout은 컴포넌트를 행과 열의 격자 형태로 배치합니다. 이 예제에서는 2x2 그리드에 버튼을 배치합니다.
 * */
