Reputation:
So I have lots of tables and lots of cell editors, with lots of stuff in them. I figured I should be reusing them, not doing new() every time since the whole thing is set getTableCellEditorComponent() but still, nearly every time I try to do it, I get "leftovers" in old cells, and other oddities. I can usually correct the problem by just making a new one every time, but is this bad?
Thanks! Joshua
Upvotes: 0
Views: 228
Reputation: 1146
Since there is always zero or one editor per JTable
, the performance of the getTableCellEditorComponent()
call is not extremely critical. Creating new components must be avoided when dealing with the table renderer, though.
Upvotes: 1
Reputation: 147164
JTable
s are huge. While the JComponent
subclass in a TableCellEditor
may also be quite large, it isn't really worth worrying about. Further, it is a good idea to avoid sharing mutable objects, particularly ones as complicated as Swing components. Having one parent per component lifetime seems a good option.
Upvotes: 1