doublemetal 2013. 7. 17. 01:09


public class ComboTest extends JFrame {

JList<String> jl;

JComboBox<String> com;

String name[] = { "수곡동", "도곡동", "용암동", "분평동", "개신동" };

String count[] = { "1", "2", "3", "4", "5" };


public ComboTest() {

super("JComponent practice");

Container c = getContentPane(); //Returns the contentPane object for this frame.

c.setLayout(new FlowLayout()); //컨테이너의 레이아웃 설정


com = new JComboBox<String>(name); //콤보박스에 name 붙임

JScrollPane s = new JScrollPane(com); //스크롤 생성

c.add(s); //컨테이너에 JScrollPane 붙임

jl = new JList<String>(count); //리스트 생성

JScrollPane s1 = new JScrollPane(jl); //리스트 스크롤 생성

jl.setVisibleRowCount(3); //화면에 보이는 행의 수

c.add(s1); //컨테이너에 JScrollPane 붙임

setSize(300, 300);

setVisible(true);

}


public static void main(String[] args) {

// TODO Auto-generated method stub


ComboTest obj = new ComboTest();

obj.setDefaultCloseOperation(EXIT_ON_CLOSE);

}

}