Analysis of Applets

1. The basics of Java Applet

1.JavaApplet is a small application written in Java language , which can be directly embedded in web pages and can produce special effects. Web pages that contain applets are called Java-powered pages, which can be called Java-powered pages.

When the user visits such a web page, the Applet is downloaded to the user's computer for execution, but only if the user is using a web browser that supports Java. Since the Applet is executed on the user's computer, its execution speed is not limited by the network bandwidth or Modem access speed. Users can better appreciate the multimedia effects produced by Applets on web pages.

In Java Applet, functions such as graphic drawing, font and color control, animation and sound insertion, human-computer interaction and network communication can be realized.

2. How Applet works.
The HTML file code of the webpage containing Applet has a pair of tags such as <applet> and </applet>. When a web browser that supports Java encounters this pair of tags, it will download the corresponding applet code and store it locally . Execute the applet on the computer.
 
3. Simple example:
A simple applet program HelloWorldApplet.java:
import java . applet . *;
import java . awt . *;
public class HelloWorldApplet extends Applet { public void paint ( Graphics g ) { g . drawString ( " Hello World " , 25 , 50 ) ; } }
 
4. Applet class

Each Applet is a subclass of the java.applet.Applet class. The base Applet class provides methods for derived classes to call to obtain browser context information and services.

In addition, the Applet class also provides an interface for the viewer or browser to obtain the information of the Applet and control the execution of the Applet.
5. applet call

Applet is a Java program, which generally runs in a Web browser that supports Java. Because it has full Java API support, Applet is a full-featured Java application.

The <applet> tag is the basis for embedding Applets in HTML files.

The following is an example of calling the "Hello World" applet;

html code:

< html > < title > Hello,World Applet </ title > < hr > < applet code = HelloWorldApplet.class width = 320 height = 120 >
If your browser has Java enabled, the "world" information will appear here. </ applet > < hr > </ html >
Reference related links: http://www.runoob.com/java/java-applet-basics.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324578708&siteId=291194637