I am using this function to create a jTable
, where some special cells have a jComboBox
as editor :
void fillTable_(){
final JComboBox myEditor = new JComboBox(new String[] {"yes", "no", "maybe"});
String[][] data = new String[10][2];
data[0][0] = "0,0";
data[0][1] = "0,1";
data[1][0] = "1,0";
data[1][1] = "1,1";
data[2][0] = "2,0";
data[2][1] = "2,1";
String[] columnNames = {"Nom", "Valeur"};
DefaultTableModel model = new DefaultTableModel(data, columnNames);
jTable1 = new JTable(model){
DefaultCellEditor myCellEditor = new DefaultCellEditor(myEditor);
@Override
public TableCellEditor getCellEditor(int row, int column){
int modelColumn = convertColumnIndexToModel(column);
int modelRow = convertRowIndexToModel(row);
if(modelColumn == 1 && modelRow == 1){
return myCellEditor;
} else {
return super.getCellEditor(row, column);
}
}
};
}
But the jTable stays empty not even plain text display. Is there something wrong?