For this purpose, so-called tags in the form of keywords, each bracketed by are used. Generally seen, the page description language HTML is used to define the Content, structure, and format of texts and images on websites on the Internet should be displayed. In order to actually make our java applet executable, we need the class first in an HTML page such as Our class Testing can therefore after compiling also cannot be started directly with the Java interpreter do a little more. The most striking difference to our frame class is certainly the lack of the main method. Again (as with the Frame) the reference to the content pane determines the layout of the container and an object of the JLabel class is created with the text to be displayed and added to the container.
Building our simple graphical interface that is still housed in the constructor for the frame was, is used in our java applet class in the init method – which is automatic later is called when the java applet starts – relocated. Since our Java program is not responsible for creating an object in our java applet class we do not need to program a constructor. Like our Frame class, we also use the instance variable c of type in the java applet Container and labeling of the JLabel type. Our Testing class now inherits from JApplet and thus becomes equipped with the prefabricated properties of a java applet.