Titel:

Java Game Programming Developement Tutorial

Startseite
english
  
ISBN: 382726300x   ISBN: 382726300x   ISBN: 382726300x   ISBN: 382726300x 
 
  Wir empfehlen:       
 

Basic structure of an applet

Well, this is very simple and the basic structure of an applet will be the same for every applet you will program. The major difference between an applet and an application is that there is no public static void main (String[]args) - method in an applet! Instead every applet should implement the following methods:

// import necessary packages
import java.applet.*;
import java.awt.*;

// Inherit the applet class from the class Applet
public class FirstApplet extends Applet
{
    // Now you should implement the following methods

    // init - method is called the first time you enter the HTML site with the applet
    public void init() {... }

    // start - method is called every time you enter the HTML - site with the applet
    public void start() {... }

    // stop - method is called if you leave the site with the applet
    public void stop() {... }

    // destroy method is called if you leave the page finally (e. g. closing browser)
    public void destroy {... }

    /** paint - method allows you to paint into your applet. This method is called e.g. if you move your browser window or if you call repaint() */
    public void paint (Graphics g) { }
}

To insert an applet to a HTML - site you have to add the following lines to your HTML document.

<html>
<body>
<p><applet code ="FirstApplet.class" width=700 height=400>
</applet></p>
</body>
</html>

This is the most important line: <p><applet code ="FirstApplet.class" width=700 height=400> .
  1. applet code ="FirstApplet.class" tells the browser where to find the "extends Applet" - class.
  2. width and height tell the browser how big the applet should be
To learn other html - tags please search for a tutorial in the internet.

Next chapter

Moving a ball
  
JSP mit Tomcat (Broschiert)
von Micha Seeboerger-Weichselbaum,
Michael Seeboerg Weichselbaum
Siehe auch:
Java Server Pages mit CD. Professionelle Web-Anwendungen mit JSP 1.X und 2.0
von Micha Seeboerger-Weichselbaum
AJAX mit Java-Servlets und JSP. So bringen Sie Speed in Ihre Webpräsenz (Open Source Library)
von Ralph Steyer
Struts Ge-Packt.
von Manfred Wolff
J2EE mit Struts & Co. Java-Projekte mit Struts, Tomcat, Jboss und Eclipse (New Technology)
von Dieter Eickstädt
 
    
     

Zurück zu Themenseiten:
StudyPaper.com/Startseite/Computer/Informatik/Programmieren/Java
StudyPaper.com/Startseite/Computer/Spiele

Das Setzen von Verweisen (Links) auf diese Seite ist gestattet und bedarf keine vorherige Absprache.
   
  Startseite  |  english  |  Bookmark setzen  |  Webseite weiterempfehlen  |  Copyright ©  |  Impressum