How to use Renderer for TableHeader

后端 未结 2 1294
难免孤独
难免孤独 2020-12-10 12:45

Even I read and test answers by @kleopatra

  • How do I correctly use customer renderers to paint specific cells in a JTable?

  • particular one t

2条回答
  •  星月不相逢
    2020-12-10 13:40

    I had this happen to me in the past and I was convinced it had to do with the Cell Renderer, but the ArraysXxxException kind of Exceptions hunted me because I had forgotten to unselect and stop editing the cell before adding/removing rows. You should try clearSelection() and table.getCellEditor().stopCellEditing(); on your JTable before remove/add and see if that solves your problem.

    First, of course, make sure it is editing:

    if (table.isEditing()) {
        table.getCellEditor().stopCellEditing();
    }
    

提交回复
热议问题