缓存JTable行 [英] Caching JTable rows
问题描述
是否可以缓存所有行渲染器,以便在表更新后仅渲染一次每一行?我预计不会有太多数据.
Is it possible to cache all row renderers so that each row is rendered just once after table updates? I am not expecting much data.
推荐答案
JTable
渲染器提供视图;除非模型的getValueAt()
实现强加了RTL渲染器,否则不应有明显的开销.而是让您的TableModel
获取其数据,仅在必要时进行缓存.此示例 extends AbstractTableModel
,并获取有关构造的全部数据.如果获取会带来延迟,请使用 SwingWorker
,如 API中所示或在此示例中.
JTable
renderers serve the view; an RTL renderer should have no perceptible overhead unless your model's getValueAt()
implementation imposes it. Instead, let your TableModel
acquire its data, caching only if necessary. This example extends AbstractTableModel
and acquires its entire data on construction. If acquisition will impose a delay, use an instance of SwingWorker
, as shown in the API or in this example.
这篇关于缓存JTable行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!