Menampilkan Gambar dengan Sun Java Wireless Toolkit 2.5.2


Output

Output


Langkah pertama yang dilakukan yaitu membuat Name Project =”Project Gambar” dan class MIDlet =”gambar”
kemudian create Project dan OK
setelah itu ambil gambar yang berekstensi PNG(.png) Contoh yang saya buat yaitu edit.png
edit.png

edit.png


Kemudian simpan pada C:\Users\LES_HAS\j2mewtk\2.5.2\apps\Project Gambar\res (ini address yang ada pada komputer saya)
Selanjutnya ketikkan code dibawa ini

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class gambar extends MIDlet implements CommandListener
{
Display display;
Form imageForm;
Command exitCommand = new Command("Exit", Command.EXIT,1);

public gambar(){
imageForm = new Form("ImageItem");
imageForm.addCommand(exitCommand);
imageForm.setCommandListener(this);

try{
Image img = Image.createImage(“/edit.png”);
ImageItem image = new ImageItem(“Bunga Mawar Yang Indah”,img, Item.LAYOUT_LEFT, “Bunga Mawar Yang Indah”);
imageForm.append(image);
} catch(Exception e){e.printStackTrace();}
}

public void startApp(){
if (display==null){
display = Display.getDisplay(this);
display.setCurrent(imageForm);
}
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}
public void commandAction(Command c, Displayable d){
if(c==exitCommand){
destroyApp(true);
notifyDestroyed();
}
}
}

Sekian dan semoga berguna bagi sahabatku 😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s