Java Applet
How to add java applets to a website
Type the code into html,
<APPLET CODE = "NameofClass.class" WIDTH=400 HEIGHT = 100></APPLET>
Then store all the class files
into the same directory as your web files.
What is a java applet?
Java Applet runs on web browsers, it's
very similar to swing applications. The differences are, instead of extending
JFrame class, applets extend the JApplet class. In JFrame, the space of a window
is managed by the host operating system's window system and in applet, the space
of the window is manage by the browser.
Here are the two methods that are
called automatically by the applet:
init();
paint();
We will see examples on both,
lets start with an example on init().

As we can see from the above
example, Applets are very similar from GUI, the only difference is it doesn't
need a main method. Now lets see an example on how to use the paint() method to
pain in applet.

Now lets see an example that we used in the Swing
chapter, then we can see how similar JApplet and swings are. If we know one then
we know both.

ClickHere to download StarbucksApplet.java
<Java
24><Home><Swing
Method & Constructor Table>
