RSS

Gambar muka Babi

16 Mei

//Yoswanto
//NIM.TKJ06100
//Kelas B

//Gambar muka Babi
//Pemanfaatan perintah g.fillArc dan g.setColor
//Langkah : (ada 2 file yang harus dibuat)

//file 1 diberi nama pig

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class pig extends MIDlet {
Display display;
private GarisLingkaran garisLingkaran;

public pig () {
display = Display.getDisplay(this);
}

public void startApp() {
garisLingkaran = new GarisLingkaran(this, display);
display.setCurrent(garisLingkaran);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void exitMIDlet() {
destroyApp(false);
notifyDestroyed();
}
};

//file ke-2 diberi nama GarisLingkaran

import javax.microedition.lcdui.*;

class GarisLingkaran
extends Canvas {
private Display display;
private pig midlet;

public GarisLingkaran(pig midlet,Display display) {
this.midlet = midlet;
this.display = display;
}

protected void paint(Graphics g) {
//tangan kiri
g.setColor (255,0,255);
g.fillArc (40,230,60,30,0,360);
//tangan kanan
g.setColor (255,0,255);
g.fillArc (120,230,60,30,0,360);
//pig
g.setColor (0,255,255);
g.fillArc (10,50,200,200,0,360) ;
//mata kiri
g.setColor (255,0,0);
g.fillArc (50,100,20,35,0,360);
//mata kanan
g.setColor (255,0,0);
g.fillArc (150,100,20,35,0,360);
//mulut
g.setColor (0,255,0);
g.fillArc (75,150,70,50,0,360);
//hidung
g.setColor (255,255,0);
g.fillArc (85,135,50,50,0,360);
//lubang hidung
g.setColor (200,0,255);
g.fillArc (98,145,10,10,0,360);
//lubang hidung 2
g.setColor (200,0,255);
g.fillArc (115,145,10,10,0,360);
}

protected void keyPressed(int keyCode) {
if (keyCode == -5) {
midlet.exitMIDlet();
}
}
};

About these ads
 
Tinggalkan komentar

Posted by pada Mei 16, 2009 in java, JDK

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
Ikuti

Get every new post delivered to your Inbox.

%d bloggers like this: