Is there any way to detect a cell selection change in a JTable? I’ve found documentation for detecting a row change using ListSelectionListener but it doesn’t seam to work when changing selection on the same row. I’m using JTable to render a simple schedule.
Maybe I should use a different component?
No, the right component for showing tabular data is JTable.
You want to add a listener to the TableModel that’s underneath the table. That will fire off events whenever data changes. You get it out of JTable, unsurprisingly enough, by calling
getTableModel().Update
Oh wait, I think I misunderstood you. You’re not interested in data changes but column selection changes.
JTable has a method called
columnSelectionChanged; its documentation says it’s called byTableColumnModelListener, which leads me to believe that what you want to do isgetColumnModel()and use theaddColumnModelListener()method of that to listen for column selection changes.