JTable Calls Custom Cell Renderer Method… Continuously

前端 未结 3 552
一整个雨季
一整个雨季 2020-11-28 15:19

Compilable source can be found at: http://www.splashcd.com/jtable.tar

I\'m new to the language, so I\'m not sure if this is acceptable behavior or not.

I cre

3条回答
  •  孤城傲影
    2020-11-28 15:57

    To get the most performance out of a TableCellRenderer, make sure you're not creating a new instance of a component every time getTableCellRenderer is called. Make the components once and save them as fields of the class.

    Also, you'll want to make sure each of the Components you use have the following methods overridden to do nothing:

    • validate
    • invalidate
    • revalidate
    • repaint
    • firePropertyChange

    (and you probably want to hard code isOpaque).

    For more information see: http://docs.oracle.com/javase/6/docs/api/javax/swing/tree/DefaultTreeCellRenderer.html

提交回复
热议问题