TableModel fire methods expensive if not visible

ⅰ亾dé卋堺 提交于 2020-01-04 05:23:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!