I would like ideas on how to make this more efficient in terms of object creation.
Rob Camick wrote:
I would like ideas on how to make this more efficient in terms of object creation.
A renderer is designed to be reused. Based on your example you have a fixed number of values for each row in the second columns.
-> this shows the limitations of examples. No, my data is not set up so that there are always the same number of percentages for each row, there might be 1, or 4, or 20. The info you've given me is valuable nonetheless, it was not clear to me to declare instance vars in the renderer class and reset their values each time getCellRendererComponent is called.
However, this won't quite cover my case. I don't even have a fixed number of percentages in the display after the table is rendered! If the user widens the window enough, he can see percentages that were too small to display when the window was narrower.
So, do you (or does anyone) have ideas about how to handle this when there are different number of percentages per row, and in fact potentially a different number when the display opens.
[And I know about using data models, etc.; I thought this was a simpler example to illustrate what I wanted to do.]
No, my data is not set up so that there are always the same number of percentages for each row, there might be 1, or 4, or 20
If the user widens the window enough, he can see percentages that were too small to display when the window was narrower.
Not sure I understand this. I would guess you still have the same number of labels added to the panel. Its jus that the size changes as the window widens so more labels will be readable.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |