티스토리 뷰

java,web study/3주차 (7월 15일 ~21일)

JTable 02

doublemetal 2013. 7. 17. 01:16


public class DataModelTest {


public static void main(String[] args) {

// TODO Auto-generated method stub


String rows[][] = { { "수곡동", "야구" }, { "모충동", "족구" }, { "개신동", "축구" } };

String headers[] = { "이름", "종목" };

String sports[] = { "야구", "축구", "족구", "기타" };


JComboBox<String> comboBox = new JComboBox<String>(sports);

comboBox.setMaximumRowCount(4);


TableCellEditor editor = new DefaultCellEditor(comboBox);

JFrame frame = new JFrame("JTable test");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JTable table = new JTable(new DefaultTableModel(rows, headers));


table.getColumnModel().getColumn(1).setCellEditor(editor);


JScrollPane scrollPane = new JScrollPane(table);

frame.add(scrollPane, BorderLayout.CENTER);

frame.setSize(300, 150);

frame.setVisible(true);

}

}






'java,web study > 3주차 (7월 15일 ~21일)' 카테고리의 다른 글

스레드 예제 (성금 모금)  (0) 2013.07.17
스레드 예제 (Bank)  (0) 2013.07.17
JTable  (0) 2013.07.17
Box Layout  (0) 2013.07.17
JComboBox  (0) 2013.07.17
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함