Meaning of getTableCellRendererComponent argument

醉酒当歌 提交于 2019-12-02 13:19:45
trashgod

JTable rendering is an example of the flyweight pattern in which a single component is moved repeatedly to render a table cell's value. The getTableCellRendererComponent() is called by the table each time the table determines the need to render a cell. As it may be called frequenly, some care should be given to efficiency. The advantage is that the rendering process can be omitted for non-visible cells. See also this related example.

Addendum: Why not just simply call table.getValueAt(row, column) instead of using value?

When it paints a cell, the table's UI delegate, typically a subclass of BasicTableUI, must invoke prepareRenderer() without knowledge of the TableModel. The contract of the table's prepareRenderer() method, which does have knowledge of the TableModel, specifies that it "Prepares the renderer by querying the data model for the value." See A Swing Architecture Overview for details.

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