Professional Documents
Culture Documents
Applet
Applet
Introduction
Java supports two kinds of programs. They are the normal standalone programs,
which are called Java applications and the programs that are to be embedded in
a Web page, called Java applets. It can display text, graphics, animation, etc,
which make Web pages attractive and interesting to view.
Applet Programming
Java is referred to as a powerful Internet programming language. Applets are the
Java programs that are executed by the Web browser. Java also provides a utility
called appletviewer to execute applets. Applet is a special class file written to
display graphics in a Web browser. Applets are embedded in Web pages using
the HTML tag <applet>.
If the applet that is embedded is stored in your own machine, it is called as local
applet.
The applets that are stored in some other computer can also be embedded in
Web pages. Such applets can be downloaded and embedded into Web pages
from the Internet. This is referred to as remote applet
1 Footnote by
Takada
Java Applet
This method is used to draw graphics in the drawing area of the applet. The
repaint() method is used whenever you want to redraw the applet’s drawing area.
The repaint() method calls the update() method. The update() method clears the
applet area and calls the paint() method.
You don’t have to define the repaint() method. To call the repaint() method, just
type repaint() followed by a colon.
2 Footnote by
Takada
Java Applet
<HTML>
<body>
Save as
<applet code=HelloJava.class width=150 height=150>
HelloJava.html
</applet>
</body>
</HTML>
3 Footnote by
Takada
Java Applet
import java.awt.*;
import java.applet.*;
<HTML>
<body>
<applet code="AppletView.class" width= 200 height=100>
</body>
</HTML>
import java.awt.*;
import java.applet.*;
g.drawString(s,100,100);
}
}
<HTML>
<body>
<applet code="Add.class" width= 200 height=100>
</body>
</HTML>
4 Footnote by
Takada