How do i add a customized CellEditorListener to my JTable?

I start typing my code:

private void addMyCellEditorListener() {

    class MyCellEditorListener implements CellEditorListener
        public MyCellEditorListener() {}

        public void editingCanceled(ChangeEvent e) {}

        public void editingStopped(ChangeEvent e) {
            if(row == 0 && column > 0)

    .... addCellEditorListener(new MyCellEditorListener());

I would like my graphicTable to detect data changes into its cells by giving it a customized CellEditorListener, but I really can't understand how to add it. I tried several times with a code like the following:

DefaultCellEditor editor = new DefaultCellEditor(new JTextLabel());
editor.addCellEditorListener(new MyCellEditorListener());

... or:

this.graphicTable.setCellEditor(this.graphicTable.getCellEditor().addCellEditorListener(new MyCellEditorListener()));

... however these techniques give me a NullPointerException in both cases.

I have looked around through forums to get a solution, but they are just getting me more confused.

Every hint would be appreciated.

Thanks in advance.


Your approach is incorrect. You can easily detect data changes in your TableModel, specifically in setValueAt method. Once you detected the change and reacted on it, you have to call one of the fireTable.. methods to let table and all other listeners know that data changed

There no need to assign any listeners to cell editors at all.

Need Your Help

source code for LINQ 101 samples


where can I find the code for GetCustomerList(), GetOrderList() for the LINQ 101 samples

SQL query to find record with ID not in another table

sql database

I have two tables with binding primary key in database and I desire to find a disjoint set between them. For example,