开发者

Prevent Java from repainting the content of a JPanel while updating

I have开发者_如何学Go a JPanel which contains a lot of child components. While updating\adding new components to the parent JPanel I'd like to prevent it from repainting, how can this achieved?


Try RepaintManager.currentManager(component).markCompletelyClean(component). It will prevent the component from repainting. You might need to do this after each time you add new components.


setVisible(false)  

update

setVisible(true)


you could try by using setIgnoreRepaint(boolean value) but it's a typical swing feature that can or cannot work (mainly because it depends from AWT so you never know).

Otherwise you could override the paint method by using a flag that simply makes the methor return without calling super.paint(). (actually overriding paintComponent should be the right choice)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜