Java Swing How to - Disable User Edits in JTable








Question

We would like to know how to disable User Edits in JTable.

Answer

//from   w w  w .j a  v a 2  s . c  om

import javax.swing.JTable;

public class Main {
  public static void main(String[] argv) throws Exception {
    JTable table1 = new JTable() {
      public boolean isCellEditable(int rowIndex, int vColIndex) {
        return false;
      }
    };
  }
}