开发者

Java swing: Remanence when removing a heavyweight jogl component to add a lightweight component at the same place

In my swing application, when I remove a jogl GLCanvas from my main component to add a jPanel at the same place, there are some display glitches: During the time when the old component has been removed and before the new one has been added, remanent images of all the popup menus that have been displayed before on top of the GLCanvas are visible on the backgro开发者_运维问答und of the main component.

How can I avoid this?


When adding/removing components from a visible GUI the code should look like:

panel.remove(...);
panel.add(...);
panel.revalidate();
panel.repaint();

Also, the code should execute on the Event Dispatch Thread. If code is executed from within a listener then it is on the EDT. If the code is executed outside of a listener then you probably need to use a SwingWorker or SwingUtilities.invokeLater().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜