在Swing中强制立即进行布局和绘制 [英] Force immediate layout and paint in Swing
问题描述
我似乎无法在Swing中强制布局.我在JLayeredPane
上添加了JComponent
,并在JComponent
上设置了边框.然后,我想立即重新绘制所有内容-不是像invalidate()
那样请尽快完成",而是同步且立即进行.有什么帮助吗?我似乎找不到正确的方法,而我对invalidate(), validate(), repaint(), doLayout(), etc
的所有阅读只会使我更加困惑!
I cannot seem to force a layout in Swing. I have a JComponent
added to a JLayeredPane
and I set a border on the JComponent
. Then, I want to immediately re-draw everything - not in the sense of "please do this asap" like invalidate()
, but synchronously and immediately. Any help? I cannot seem to find the right method of doing this, and all my reading about invalidate(), validate(), repaint(), doLayout(), etc
is just confusing me more!
推荐答案
According to this (see the section titled "Synchronous Painting") the paintImmediately() method should work.
这篇关于在Swing中强制立即进行布局和绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!