Welcome to the Ranch
So you think we're helpful? You've fallen into my hands! Mwaaahaaahaahaa!
I see Fred has been at your post and added
code tags, and you can see how much better it looks. If you click the code button before writing the code, go left 7 places so your cursor is between the first ] and the second [, where there is no gap. That is by no means a huge post; it fits easily onto my 11 inch screen. I shall move your post, however, because we usually discuss GUIs on another forum.
It works all right for me. I went to GIMP, drew a little devil, which I won't give you because I am embarrassed about its artistic quality (or crappiness), and saved that in a folder created specially for the occasion, called devil. Then I copied your .java file into that, with this one change: public class LabelDemo instead of labelDemo.
So now we have this folder structure
Then I compiled it with javac -d . LabelDemo.java and now we have this sort of structure:[
Then I ran it with java labelDemo.LabelDemo. And wondered, did he voluntarily choose cyan for the background?
I think you are supposed to use something like getClass().getResource("devil.gif"), which is discussed in a
recent thread.
That won't work because you are working in a
static context. You ought not to put everything into the main method anyway. It is better to set up a GUI in a constructor or a (private void) method like "initComponents()" or "setUpGUI()".