Swing: most computationally-efficient way to blink particular cells in a table

前端 未结 1 1831
孤独总比滥情好
孤独总比滥情好 2021-01-21 02:02

I need a way to draw attention to particular cells in a large JTable (20x16!), and I want to know what it would take for the text to blink, e.g. 900msec on and 100msec off.

相关标签:
1条回答
  • 2021-01-21 03:04

    The required duty cycle (900 ms on, 100 ms off) and count (20 x 16) is well within the capability of JTable rendering, which uses the flyweight pattern for efficiency. On the rare occasion when profiling warrants, see the article Christmas Tree Applications. See also this comparison with the prepareRenderer() approach.

    Addendum: Also consider a GridLayout of JLabel, with each button having it's own instance of javax.swing.Timer to avoid synchronous blinking. The timers share a common thread.

    0 讨论(0)
提交回复
热议问题