Skip to main content

GUI Applet doesn't render correctly the 1st time

2 replies [Last post]
Joined: 2005-06-30

I'm developing a rather involved GUI that is implemented as an applet. It's working very nicely except that it never renders correctly the first time. I always have to refresh the browser at least once before it will render the applet correctly. After I refresh the browser at least once then it will always render the applet on the first invocation.
I am using the standard invocation code implemented in the "start()" method as follows,
// Execute GUI
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
} catch (Exception e) {
System.err.println("Error in creating GUI: " + e.getMessage());

Any ideas as to why it takes a browser refresh to render correctly the first time?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-09-04

Initialize the GUI in the init() method using the SwingUtilities.invokeAndWait methodology.

Joined: 2005-06-30

I initially had the GUI creation code in the "init()" method and thats whenI discovered the refresh issue. I moved it to the "start()" method because I thought that there was a timing issue in the JVM.
The only components that display initially are the text only JLabels and the contentpane border. The JLabels that have images, JButtons and the glasspane all require an initial refresh to be rendered correctly at startup.