Its work as you want. After click the disable button cell editing will stop.
public class TestTable {
boolean flag = false;
public void create() {
JTable table = new JTable(2, 2) {
public boolean isCellEditable(int row, int column) {
if (flag) {
return false;
}
return true;
}
};
JFrame f = new JFrame();
JButton button = new JButton("Disable");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag = true;
}
});
f.setLayout(new FlowLayout());
f.add(new JScrollPane(table));
f.add(button);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TestTable().create();
}
});
}