Reputation: 71
i just enter some details in JTable. and store those details in my database with specific id. But if i retrieve those details in my JTable based on id, on that time the JTable should not allow edit operation in it. it just for view purpose. How can i set whether Jtable is editable or not based on user selection. (Insert, Search)
Upvotes: 1
Views: 41
Reputation: 418575
Take a look at and TableModel.isCellEditable(int rowIndex, int columnIndex).
You have to use a TableModel
and override its isCellEditable()
method in which you can tell which cells you want to allow editing based on the row and column indices.
Note: There is a JTable.isCellEditable(int row, int column) too which calls the model's isCellEditable()
method.
Upvotes: 1
Reputation: 347334
Editability is controlled, primarily, through the isCellEditable
method of the TableModel
.
You could establish a setting within your TableModel
which can return false
when you want the model to be read only.
See How to Use Tables for more details
Upvotes: 1