created: 03/07/1998; revised: 07/15/2002, 08/18/2003, 11/02/2003, 02/11/2006, 12/03/2010
Note: Oracle, the company responsible for Java, is dropping support for Java applets in the Java Development Kit 9, expected in March 2017. Applets will be completely removed from the JDK and the Java Runtime Environment.
If you have not started these chapters on applets, you should skip them and the occasional pages in other chapters that use applets.
JApplet
classpaint()
methodGraphics
classGraphics
class:
setColor()
drawOval()
drawRect()
drawLine()
This chapter can safely be skipped. Applets are only used occasionally in the following chapters.
This chapter examines Java applets. An applet is an object that can be part of a web page much like an image can be part of a web page. The applet is written in Java and compiled just as any Java program. An applet controls the graphical components and user interaction in a rectangular section of the Web browser's screen.
When you view a page that contains an applet, the applet's bytecode is transferred to your computer and executed by a Java Virtual Machine that is part of the web browser. The output of the applet is displayed in a rectangular portion of the browser. However, your browser must have applets enabled. If your browser is has applets enabled, you will the following applet, which displays a circle in a white rectangle.
These notes discuss the
JApplet
class that
is part of the Swing set of components.
(Thought Question: ) Is an applet a Java application?