Dynamically rearrange layout with Swing

百般思念 提交于 2019-12-05 10:12:57
trashgod

Although dynamic layouts are possible, as shown here and here, I'd use a one-column JTable with a TableModel that reflects the pushdown stack effect you want, perhaps one having an internal Queue<Tweet>. JTable rendering is efficient, and the component works well in a JScrollPane.

Short answer, no. Seriously, take a moment to think about the question. "I want to add new content, but not update the screen", how feasible do you think that is?

You're going to have to perform some kind of painting eventually. The question is how often.

However...

With some simple techniques (and modeling) you can "coalesce" the updates into batches, allowing the repaint to be more meaningful (rather then painting each new tweet, you paint a batch).

You could use something like a SwingWorker to do this. Basically publish the tweet and allow the process method to deal with adding the chunks afterwards.

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