Subscribe to RSS Feed

Jumat, 08 Juni 2012

TULISAN 1: MEMBUAT PROGRAM DATE AND TIME PADA J2ME

Ini adalah contoh program sederhana yang dapat dibuat dengan menggunakan j2me...




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

public class Kalender extends MIDlet implements CommandListener,ItemStateListener
{
private Display tampil;
private Form form;
private Command cmdExit;
private DateField df;

public Kalender()
{
tampil = Display.getDisplay(this);
df = new DateField(“Tanggal Sekarang : “,DateField.DATE);
df.setDate(new java.util.Date());
cmdExit = new Command(“Keluar”,Command.EXIT,0);
//Menambahkan aksi keluar
form = new Form(“Kalender J2ME”); //Title Form
form.addCommand(cmdExit);
form.append(df);
form.setCommandListener(this);
form.setItemStateListener(this);
}

public void startApp()
{
tampil.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}

public void commandAction(Command com,Displayable dis)
{
if(com == cmdExit)
{
destroyApp(true);
notifyDestroyed();
}
}

public void itemStateChanged(Item itm)
{
df.setLabel(“Tanggal Baru: “);
}
}

Tampilan


0 komentar:

Posting Komentar