Click to See Complete Forum and Search --> : JTable


Deepika Sachdev
January 6th, 2000, 11:29 PM
I am using JTable to diaplay records retrieved from the DataBase. The Data is diaplayed by passing an AbstractDataModel to the JTable.

My requirement is that the data in my JTable should be read-only and no user should be able to add, modify or delete data from this JTable.
Is there any property which can be set to make my JTable read-only.

Chris Allen
January 7th, 2000, 06:31 AM
JTable doesn't have a specific flag for disabling editing but you can set them so tey can't be selected.


jTable1.setCellSelectionEnabled(false);




You will still be able to view the data but cell modification will be disabled.

Chris.

nguyevu
January 7th, 2000, 09:58 AM
Another alternative is to override the isCellEditable in the TableModel to return false all the way

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