Académique Documents
Professionnel Documents
Culture Documents
BAHASAN
PENDAHULUAN
BEDA APLIKASI DAN APPLET
MEMBUAT APPLET
MEMASUKKAN APPLET KE
HALAMAN WEB
APPLET TAG
JAVA ARCHIVE
PASSING PARAMETERS TO
APPLETS
APPLET - PENDAHULUAN
Program Java yang berada pada
MEMBUAT APPLET
Buat subclass dari class
Applet dengan
inisialisasi sebagai berikut:
public class myClass extends
java.applet.Applet {
...
}
Starting
Stop
Destroy
Tampilan Applet
9:
10:
11:
<HTML>
<HEAD>
<TITLE>This page has an applet on it
</TITLE>
</HEAD>
<BODY>
<P>My second Java applet says:<BR>
<APPLET CODE="HelloAgainApplet.class"
WIDTH=200 HEIGHT=50>
alt="Your browser understands the APPLET tag
but isn't running the applet, for some reason."
Your browser is completely ignoring
the <APPLET> tag!
</APPLET>
</BODY>
</HTML>
Code
CODE, CODEBASE, ARCHIVE, OBJECT, NAME
Java-Challenged Viewer
ALT (MENAMPILKAN PESAN ADANYA APPLET JAVA
PADA SUATU HALAMAN WEB)
Vertical-Horizontal Space
VSPACE=50 HSPACE=10
Aplikasi Applet
Buat halaman HTML untuk load applet
code
Suplai subclass dari class JApplet (public)
Hilangkan method main pada aplikasi
Pindahkan kode inisialisasi dari frame
window constructor ke method init applet
Hilangkan panggilan ke setsize, show
setTitle & setDefaultCloseOperation
file HTML
HTML tag <PARAM>, dengan atribut NAME
dan VALUE yang ingin di-define:
<APPLET CODE="MyApplet.class" WIDTH=100 HEIGHT=100>
<PARAM NAME=font VALUE="TimesRoman">
<PARAM NAME=size VALUE="36">
A Java applet appears here.</APPLET>
applet di-load
terjadi saat
1: import java.awt.Graphics;
INSTANCE
2: import java.awt.Font;
VARIABLE
3: import java.awt.Color;
UNTUK NAME
4:
5: public class MoreHelloApplet extends java.applet.Applet {
6:
7: Font f = new Font("TimesRoman", Font.BOLD, 36);
8: String name;
9:
SET VALUE
10: public void init() {
UNTUK NAME
11:
name = getParameter("name");
DENGAN
12:
if (name == null)
METHOD INIT ()
13:
name = "Laura";
14:
15:
name = "Hello " + name + "!";
16: }
17:
MODIFY NAME
18: public void paint(Graphics g) {
UNTUK
19:
g.setFont(f);
MEMPEROLEH
20:
g.setColor(Color.red);
STRING LENGKAP
21:
g.drawString(name, 5, 40);
22: }
23: }
HTML
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Tampilan MoreHelloApplet
Tampilan MoreHelloApplet
(null version)
SEKURITAS
Applet tidak bisa read atau write ke sistem
Positioning Attributes
ATTRIBUTE
WHAT IT DOES
LEFT
Places the applet at the left margin of the page. Text that follows
on the page goes in space to the right of the applet.
RIGHT
Places the applet at the right margin of the page. Text that follows
on the page goes in space to the left of the applet.
BOTTOM
Places the bottom of the applet at the bottom of the text in the
current line.
TOP
Places the top of the applet with the top of the current line.
TEXTTOP
Places the top of the applet with the top of the text in the current
line.
MIDDLE
Places the middle of the applet with the baseline of the current
line.
ABSMIDDLE
Places the middle of the applet with the middle of the current line.
BASELINE
Places the bottom of the applet with the baseline of the current
line.
ABSBOTTOM
Places the bottom of the applet with the bottom of the current line.
VSPACE, HSPACE
ALIGN
WIDTH, HEIGHT
ATTRIBUTE
CODE
Code Attributes
WHAT IT DOES
OBJECT
NAME