How would I be able to set certain columns of a JTable to be editable/not editable in Jython?
My table:
self.table_data = []
data_model = DefaultTableModel(self.table_data, self.colnames)
self.table = JTable(data_model)
self.table_pane = JScrollPane()
self.table_pane.setPreferredSize(Dimension(480,370))
self.table_pane.getViewport().setView(self.table)
You can do this with Jython by extending the isCellEditable method of the DefaultTableModel class:
In this example, all columns would editable except the second column (index 1), and of course, the isCellEdited logic can be refined for any specific cell or column. Just use
ifandelifstatements to set conditions that returnTrueif the cell is to be editable orFalseif the cell is to be not editable. Finally, set a default return of eitherTrueorFalseif none of the conditions are met.