Details
Applet can be translated into a small application, Java Applet is some of the small applications written in Java language, which can be embedded directly into the web and can produce special Effect. The web page containing the applet is called the Java-Powered page, which can be called a web page supported by Java.
When the user accesses such a web page, the applet is downloaded to the user's computer, but the user is using a network L browser that supports Java. Since the applet is performed on the user's computer, its execution speed is not limited by the network bandwidth or the MODEM access speed. Users can better appreciate the multimedia effects generated on the webpage.
In Java Applet, graphical drawing, font and color control, animation and sound insertion, human-computer interaction, and network communication. Applet also provides a window Environment Development Tool called Abstract Window Toolkit, AWT. AWT uses the user's GUI element to establish a standard graphical user interface, such as windows, buttons, scroll bars, and more. Currently, there are very many applet examples on the network to vividly present these features, readers can went to view the corresponding web pages to view their effects.
Applet works.
HTML file code in the HTML file code containing Applet With such a pair, when the Java's web browser encounters this pair, The corresponding small application code is downloaded and the applet is executed on the local computer.
Example
Homepage
an esample homepageWelcome to my homepage!
this is an example.comEmepage, you Can see an applet in it.
The above example is a simple home page HTML file code.
in the fifth line of the code is to ensure that Applet appears in a new line. If there is no, Applet will follow the last word of the last line. The sixth line of the code is some parameters about applet. The sixth line is the necessary Applet parameters, define the file name containing the applet byte code, which is usually ".class"; and the initial width and height of the Applet in pixels. The seventh line is an additional applet parameter, which is made by a separate tag, which is the value of the IMG is "example.gif", which represents a graphic file name.
Applet downloads the same time as a graphic file, after several seconds, it can be displayed on the screen. Waiting time depends on the size of the applet and the speed of the user's network connection. Once download, it is The program on the local computer runs in the same speed. When executed on the user's computer, you can download other resources, such as sound files, image files, or more Java code, some applets. The user is also allowed to interactively operate. But this requires repeated links and downloads, so the speed is very slow, this is an urgent problem to be solved, and a good way to think is to use a technology similar to the cache, will download each download Both are temporarily stored on the user's hard drive, although the time spent in the first time is more, but when used again, just read the file directly from the hard disk without having to connect with the Internet, it can greatly improve performance.
import java.awt. *;
import java.applet. *;
public class helloapplet extends applet {
public void Paint (graphics g) {
g.drawstring ("HelloWorld!", 50, 25);
}
}
HTML Test PageHelloApplet Will Appear Below In a java enbaled broswer.
(Java Applet program cannot be run separately, you must embed the web page written in the HTML language, control execution by compatible browser compatible with Java