Chapter 20. Applets
One of the original tenets of Java was that applications would be delivered over the network to your computer. Instead of buying a shrink-wrapped box containing a word processor, you would pay per use for a program available over the Internet. This revolutionary idea has been temporarily shelved by the realities of a slow Internet. But small downloadable applications called applets are practical and interesting.
An applet is part of a web page, just like an image or hyperlink. It “owns” some rectangular area of the user’s screen. It can draw whatever it wants and respond to keyboard and mouse events in that area. When the web browser loads a page that contains a Java applet, it knows how to load the classes of the applet and run them.
This chapter describes how applets work and how to put them in web pages. You’ll learn how to use Sun’s Java Plug-In to take advantage of the latest Java features. Finally, we’ll cover the details of creating signed applets, which can step outside the typical applet security restrictions to do useful things, like reading and writing files.
The JApplet Class
If
you’ve been waiting for a more detailed discussion of the
applet class, here it is. A JApplet is something
like a Panel with a mission. It is a GUI container that has some extra structure to allow it to be used in an “alien” environment, such as a Web browser. Applets also have a lifecycle that lets them act more like an application than a static component, such as a paragraph ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access