Friday, June 25, 2010

How to make JTable cell not Editable?

Implement the isEditable() method in your table model and return false and you table will not be editable.

Example:

public class MyTableModel extends AbstractTableModel{

public void isEditable()
{
return false;
}
}

Then you have a table and you set its model to a MyTableModel object
ex.

JTable table = new JTable();
table.setModel(new MyTableModel());

No comments:

Post a Comment