简体   繁体   中英

How to know if a row of Jtable is editable?

I have a Jtable with rows brought from the database, but it depends on a condition I enable or disable the row and I can not check or edit anything in it.

I need to know which of those rows are disabled

please check this :

  public boolean isCellEditable(int row,int cols) {

               if(cols==0 ){return false;}

                //It will make the cells of Column-1 not Editable

                return true;                                                                                    

             }

to control which cells are editable, you will need to extend either JTable or JTableModel (see the call to the model in the example below) to ensure that this method from JTable returns true for all the cells in the row(s) you want editable based on your spec.

 public boolean isCellEditable(int row, int column) {
      return getModel().isCellEditable(row, convertColumnIndexToModel(column));
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM