开发者

Refreshing the Contents of a Box after changing the contents

I have a java Box in which are various components. When the user performs an action, I want to empty the box, put a different set of components in it and then represent the box to the user. The box is part of a JDialog box. I am able to empty the box and repopulate it, but the display does not reflect the new contents. It is simply a blank display (I assume reflecting the fact that I emptied the contents of the box). I repaint the box after I put the new contents in but the display is blank in the area where the box is. Oddly enough, if I first add a line border to the box, then repaint it, the contents of the Box appear on the screen. This is most bizarre behavior. Any ideas why this is happening and how to get around this problem?

Thanks,

Ell开发者_如何学JAVAiott


Are you adding and removing the contents from the EDT? if this is occuring on the wrong thread weird repaint behavior can result.

Also might want to try

dialog.revalidate() 

if the above is not the issue instead of calling repaint

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜