Q:

Java: How can I know if my TableModel has a TableModelListener?

I'm quite new to Java and I've been developing a GUI with a jTable.
I've got a jTable from which I want to track changes, so I dinamically added  a TableModelListener to its TableModel.
However, some changes are made in the table that I don't want to keep track of, so I need to somehow switch on and off the  TableModelListener.
How can I know if I already have a listener in that model?
if (/* is there an event listener for the TableModel*/){        
    listVersions.getModel().removeTableModelListener(checkBoxListener);
    }
functionModifyingTable();
listVersions.getModel().addTableModelListener(checkBoxListener);

My intention is to prevent mycode from switching off a listener that doesn't even exist.

A:

Cast table model to AbstractTableModel and use getTableModelListeners().
((AbstractTableModel) listVersions.getModel()).getTableModelListeners();

