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

0


a source to share


2 answers


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.



+1


a source


Since there is always zero or one editor per JTable

call, the performance of the call is getTableCellEditorComponent()

not extremely critical. However, creating new components should be avoided when working with the table renderer.



+1


a source







All Articles