TableModel fire methods expensive if not visible

2019-07-15 06:08发布

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.

2条回答
地球回转人心会变
2楼-- · 2019-07-15 06:17

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.

查看更多
家丑人穷心不美
3楼-- · 2019-07-15 06:28

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.

查看更多
登录 后发表回答