I’m trying to make to make some text appear before my applet loads so I’ve made a simple SSCCE(.org):
import java.awt.*;
import javax.swing.*;
public class test extends JApplet {
public void init() {
this.add(new JLabel("Button 1"));
System.out.println("Hello world...");
try {
Thread.sleep(3000);
}catch(Exception hapa) { hapa.printStackTrace(); }
}
}
If you run it, the Button 1 will appear AFTER the 3 seconds when it’s suppose to appear BEFORE that… what am I doing wrong?
JustinKSU covered the technical part of the question.
A better strategy would be to use the
imageparamto show a ‘splash’ before the applet appears. See Special Attributes of Applets for further details.In that case, put a
CardLayoutin the applet. Add the ‘splash’ to the first card, the rest of the GUI to another. At the end of theinit()create a non-repeating SwingTimerthat will flip to the card with the main GUI.E.G.