Java – make columns uneditable in JTable
•
Java
I use NetBeans to create a masterdetail simple form, and I have a JTable related to the database
I want to edit the columns in this JTable so that they are not editable
I searched all this with Google, and I found all this:
this.masterTable.getColumn("Validation").setEditable(false);
Which is not for me!
Solution
Override the iscelleditable (...) method of tablemodel
DefaultTableModel model = new DefaultTableModel(...) { @Override public boolean isCellEditable(int row,int column) { // add your code here } } JTable table = new JTable( model );
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码