Java – defaulttablemodel makes cells non editable JTable
•
Java
See English answers > how to make a JTable non editable
JTable table = new JTable(...){ public boolean isCellEditable(int row,int column){ return false; } };
Like to say: I don't like this It doesn't conform to the training rules of my school
Is there any way to do this? Maybe there's a good way I hope so!
Solution
You should not classify JTable itself, but the table model:
DefaultTableModel myModel = new DefaultTableModel(...) { @Override public boolean isCellEditable(int row,int column) { return false; } }
Or better yet, instead of using the defaulttablemodel, use the abstracttablemodel that directly gets the information in the business object, instead of copying all the information in the business object to vectors
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
二维码