JavaApplet@UbuntuGutsy
-> install Java Compiler
# sudo apt-get install sun-java6-jdk
-> install GNU Compiler for Java
# apt-get install gcj
->buat file dengan nama bonus.java
#nano bonus.java
contoh source :
import java.applet.Applet;
import java.awt.*;
public class bonus extends Applet
{
final int N = 20;
int x1[] = new int[N];
int y1[] = new int[N];
int x2[] = new int[N];
int y2[] = new int[N];
Color warna[] = new Color[N];
public void init()
{int i=0;
for (;i<N;i++)
{
x1[i]=N;y1[i]=N+i*N;
x2[i]=N+i*N;y2[i]=N*N;
}
warna[0]=Color.red;
warna[1]=Color.blue;
warna[2]=Color.green;
warna[3]=Color.yellow;
warna[4]=Color.magenta;
}
public void paint (Graphics g)
{
int i;
Color temp=g.getColor();
for (i=0;i<N;i++)
{
g.setColor(warna[i]);
g.drawLine(x1[i],y1[i],x2[i],y2[i]);
}
}
public static void main(String args[])
{
Frame f= new Frame (“0604013 Boer’Z”);
bonus boerz = new bonus();
f.resize(300,300);
f.add (“Center”, boerz);
f.show();
boerz.init();
}
}
-> Compile FIle Java
# javac bonus.java
klo berhasil, tidak akan muncul apah2,tp klo error, bkl muncul keterangan error
-> Buat File HTML
#nano bonus.html
contoh source :
<html>
<body>
<applet code=”bonus” width=”300″ height=”300″></applet>
</body>
<html>
lalu, jalankan file html tadi di browser…klo grafiknya muncul, brarti berhasil… ^^
No comments yet.










