How do I refresh a GUI in Java?

Swing components have a repaint(), revalidate(), and doLayout() method. One of those should probably be able to redraw whichever pieces you want. However, doLayout is not something that you should be taking responsibility for, that’s the layout engines responsibility.

You may also want to check out this post, the first response has a pretty good explanation, and links to an article with more detail.

In terms of the second part of your question, I’m not sure, but we may need to see some code to get an idea. Is the ‘replaced area’ actually being removed from the view?

Leave a Comment