[求助]请问怎么在JTable中加入JComcoBox
RT 谢谢了----------------解决方案--------------------------------------------------------
private JTable createTable(int nRows) {
String[] ABC = {"" , "", "", "" } //你的JComboBox选项
String[] colNames = {"" , "", "", "" } //每列的名字
for(int i = 0; i < nRows; i++ ) {
for( int j = 0; j < colNames.length; j++ ) {
rowData[i][j] = "" //表格初始化
JComboBox abc = new JComboBox(ABC);
JTable table = new JTable(rowData, colNames);
table.getColumnModel().getColumn(1).setCellEditor(
new DefaultCellEditor(abc));
//getColumn(1)这里的参数是 JComboBox abc 所在的列数
return table;
}
[此贴子已经被作者于2006-12-11 1:30:43编辑过]
----------------解决方案--------------------------------------------------------