Search code examples
javaswingjtableabstracttablemodel

JTable with AbstractTableModel does not edit on click


I am constructing a JTable for an Applet that should be able to handle user edits. As such, I have extended the AbstractTableModel and have successfully populated the table with data. My problem is that once the data has been populated, clicking on the table does not allow for edits.

I have overridden the isCellEditable() method to always return true, as well as print a message to the console every time the method is invoked. However, when I interact with the table (through any number of consecutive mouse clicks on any given single cell), the cell does not become editable, and isCellEditable() never gets called either.

My question is, what needs to be called in order to edit a particular cell? I apologize for the lack of code in the post, but the code is highly proprietary, and my superiors are very strict on releasing any code.


Solution

  • 1.are you added AbstractTableModel to the JTable already visible on the screen

    2.if yes then codes lines isn't isCellEditable(), but should be

    @Override
    public boolean isCellEditable(int row, int column) {
        return true;
    }
    

    3.I'd suggest to use DefaultTableModel rather than to override required methods for AbstractTableModel