在Swing中强制立即进行布局和绘制 [英] Force immediate layout and paint in Swing

查看:91
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆