package CHAPTER10;

import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;

public class JListExample extends JFrame {
	public JListExample() {

		JList<String> list = new JList<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" });

		// JScrollPane에 JList 추가하여 스크롤 가능 영역 제공
		add(new JScrollPane(list));

		// JFrame 설정
		setTitle("JList Example");
		setSize(300, 100);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}

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