main class is for java application. The code is for creating java applet.
I am not familiar with NET BEANS , however, I think you need to change your selection from application to applet.