Hi everybody,
Can anyone here tell me what the following code does
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel lbl = new JLabel("Hello World");
add(lbl);
}
});
It looks strange. I can't understand the syntax. Could anyone please explain what is this. I know
Thread can be created by extending Thread class/implementing runnable.
But strange part here is it is creating an object by newing a Runnable which is an interface.
Thanks,
Vivek.