You can set the column type for a JTable by setting its model explicitly like in the following example
setModel(new DefaultTableModel(new Object[0][], new String[] {
"SELECT", "WHERE", "FIELD", "TYPE" }) {
Class[] types = { Boolean.class, Boolean.class, String.class,
String.class };
boolean[] canEdit = { true, false, false, false };
@Override
public Class getColumnClass(int columnIndex) {
return this.types[columnIndex];
}
public boolean isCellEditable(int columnIndex) {
return this.canEdit[columnIndex];
}
});
Give your column classes like this (here column one and two are Boolean and the rest String.
Class[] types = { Boolean.class, Boolean.class, String.class,String.class };
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…