Selasa, 02 Juli 2013

Menampilkan Ticker dan Image pada Wireless Toolkit



Untuk membuat aplikasi ini, maka kita harus mengetikkan program seperti dibawah ini pada textpad:


import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CobaMidlet extends MIDlet implements CommandListener {
private Display display;
private Form form, login;
private Ticker ticker;
private Command Start, exit, back;
private Image img;

private ImageItem img2;
private TextField tf_Username;
private TextField tf_Password;
public CobaMidlet(){
form = new Form("");
ticker=new Ticker("SELAMAT DATANG DI POLITEKNIK NEGERI SRIWIJAYA PALEMBANG");
form.setTicker(ticker);
try {
img = Image.createImage("/graha.jpg");
img2 = new ImageItem("Jl. Srijaya Negara Bukit Besar 30139 Telpon:+620711353414 www.polsri.ac.id", img,ImageItem.LAYOUT_CENTER,"");
form.append(img2);
form.setCommandListener(this);


Start = new Command("Start", Command.OK,1);
exit = new Command("Exit", Command.OK,1);
form.addCommand(Start);
form.addCommand(exit);

} catch (IOException e){
System.out.println("error"+e);
}
}
public void startApp(){
display=Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
notifyDestroyed();
}
public void commandAction(Command c , Displayable dd){
if (c==exit)
destroyApp(true);
else if (c==Start)
display.setCurrent(form);
}
}


kemudian simpan dalam format .java

lalu build pada wireless toolkit, kemudian run

maka akan keluar seperti gambar dibawah ini:





1 komentar:

Pengikut

Chullie~

Chullie~