Can any one tell me what is the actual difference between this two codes as they both produce same result?
code1:
public class JLabelDemo extends JApplet {
public void init() {
this.setSize(400, 400);
ImageIcon ii = new ImageIcon("Flock_icon.png");
JLabel jl = new JLabel("<<--- Flock_icon", ii, JLabel.CENTER);
add(jl);
}
}
code2:
public class JLabelDemo extends JApplet {
private static final long serialVersionUID = 1L;
public void init() {
this.setSize(400, 400);
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
makeGUI();
}
});
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void makeGUI() {
ImageIcon ii = new ImageIcon("Flock_icon.png");
JLabel jl = new JLabel("<<--- Flock_icon", ii, JLabel.CENTER);
add(jl);
}
}
I really didn't find any difference between the outputs generated. But I cant understand the code.
So can anyone give me the real world example of invokeAndWait method??