Creating an Applet

When the Java language was introduced, the language feature that got the most attention was applets, Java programs that run on web pages. You can run them in any web browser that handles Java programs and test them with appletviewer, a tool included in the JDK that’s supported in NetBeans.

The structure of applets differs from applications. Unlike applications, applets do not have a main() block. Instead, they have several sections that are handled depending on what is happening in the applet. Two sections are the init() block statement and the paint() block. init() is short for initialization, and it is used to take care of anything that needs to be set up as an applet first runs. The paint() block is used to display anything ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.