问题
in the java swing tablemodel, we are able to fire table changed, added, deleted etc. I am wondering if these method calls are expensive if the component is NOT in visibility?
For instance, another window is covering it. Or its in an non-active tab.
回答1:
To minimize the impact of firing a large number of update events, JTable
renderering uses the flyweight pattern to render only visible cells. The approach is outlined here. This related example scales well into the thousands of rows, but you should profile to verify the desired performance.
I noticed lag in the swing application often on a view with static text, whilst there are heavy table updates in a hidden tab component.
As shown here, use SwingWorker to manage indeterminate latency.
回答2:
I think is depends on the application itself on how to respond to these events.
Suppose you need to perform some kind of background tasks based on these event it would still be useful.
来源:https://stackoverflow.com/questions/39168615/tablemodel-fire-methods-expensive-if-not-visible