-1

i am having difficulties in making my table cells uneditable. I don't know how. The data from my table came from my database in MySQL. Please help me make my table cells uneditable because I don't want users to edit the data displayed in each cell. Thank you!

chesca
  • 56
  • 1
  • 2
  • 7
  • 1
    see http://stackoverflow.com/questions/8372799/making-jtable-cells-uneditable http://stackoverflow.com/questions/1990817/how-to-make-a-jtable-non-editable http://stackoverflow.com/questions/18795791/how-to-make-individual-cell-of-a-jtable-uneditable http://stackoverflow.com/questions/24726896/how-to-make-cells-of-jtable-non-editable-but-selectable – Emerson Cod Oct 20 '15 at 11:06

1 Answers1

0

Hi just use in your JTable model

public boolean isCellEditable(int row, int col) { return false; }

edasssus
  • 331
  • 4
  • 15
  • but where can I insert the codes? – chesca Oct 20 '15 at 11:17
  • tblBooks.setModel(DbUtils.resultSetToTableModel(rs)); – chesca Oct 20 '15 at 11:18
  • Look over [here](https://docs.oracle.com/javase/tutorial/uiswing/components/table.html) its oracles table tutorial/documentation and you should have in your project class which extends `AbstractTableModel` and in that class you can override method `isCellEditable(int row, int col)`. – edasssus Oct 20 '15 at 11:34