Reusing TableCellEditor Objects
So I have a lot of tables and a lot of cell editors, they have a lot of stuff in them. I figured I should reuse them without doing new () every time, since it's all set by getTableCellEditorComponent (), but still, almost every time I try it, I get leftovers in old cells and other oddities ... I can usually fix the problem by just creating a new one every time, but is that bad?
Thanks! Joshua
JTable
huge. While the subclass JComponent
in TableCellEditor
can be quite large as well, it really isn't worth worrying about. It is also a good idea to avoid exchanging mutable objects, especially those as complex as Swing components. Having one parent for one period of life seems like a good option.
a source to share