Hello experts:
My SSCCE for this question is at the below link:
http://forum.java.sun.com/thread.jspa?threadID=5293914&messageID=10244030#10244030
My question is how do I disable cell editing for all but the "Price" column of my table in the SSCCE. I tried adding the below lines of code right after creating the JTable. But get compilation errors.
//Here is the block of code that I am trying to include.
@Override
public boolean isCellEditable(int row, int col) {
if (col == 7) {
return true;
} else {
return false;
}
}
//Below is the method in detail03.java showing the block of code added
private JScrollPane BuildEmptyTable() {
model = new DefaultTableModel();
model.addTableModelListener( this );
model.setColumnIdentifiers(new String[] { "SKU","Qty", "Price"});
tblDetailTest = new JTable(model);
@Override
public boolean isCellEditable(int row, int col) { // <----- I tried placing the
if (col == 7) { // the code block here
return true;
} else {
return false;
}
}
tblDetailTest.setRowHeight(20);
tblDetailTest.setPreferredScrollableViewportSize(new Dimension(900, 100));
JTableHeader tblHdr = tblDetailTest.getTableHeader();
tblHdr.setBackground(Color.yellow);
JScrollPane scrollPane = new JScrollPane(tblDetailTest);
return scrollPane;
}
Can somebody please guide me? Thank you very much.