Accessing Commands


<strong>/*————————————————–</strong>
<strong>* AccessingCommands.java</strong>
<strong>*</strong>
<strong>* Example from the book: Core J2ME Technology</strong>
<strong>* Copyright John W. Muchow http://www.CoreJ2ME.com</strong&gt;
<strong>* You may use/modify for any non-commercial purpose</strong>
<strong>*————————————————-*/</strong>
<strong>import javax.microedition.midlet.*;</strong>
<strong>import javax.microedition.lcdui.*;</strong>

<strong>public class AccessingCommands extends MIDlet implements CommandListener</strong>
<strong>{</strong>
<strong> private Display display; // Reference to Display object</strong>
<strong> private Form fmMain; // A Form </strong>
<strong> private Command cmExit; // A Command to exit the MIDlet</strong>

<strong>public AccessingCommands()</strong>
<strong> {</strong>
<strong> display = Display.getDisplay(this);</strong>

<strong>cmExit = new Command(”Exit”, Command.EXIT, 1);</strong>

<strong>fmMain = new Form(”Core J2ME”);</strong>
<strong> fmMain.addCommand(cmExit);</strong>
<strong> fmMain.setCommandListener(this);</strong>
<strong> }</strong>

<strong>// Called by application manager to start the MIDlet.</strong>
<strong> public void startApp()</strong>
<strong> {</strong>
<strong> display.setCurrent(fmMain);</strong>
<strong> }</strong>

<strong>// A required method</strong>
<strong> public void pauseApp()</strong>
<strong> { }</strong>

<strong>// A required method</strong>
<strong> public void destroyApp(boolean unconditional)</strong>
<strong> { }</strong>

<strong>// Check to see if our Exit command was selected</strong>
<strong> public void commandAction(Command c, Displayable s)</strong>
<strong> {</strong>
<strong> if (c == cmExit)</strong>
<strong> {</strong>
<strong> destroyApp(false);</strong>
<strong> notifyDestroyed();</strong>
<strong> }</strong>
<strong> }</strong>
<strong>}</strong>

Tinggalkan Balasan

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

Logo WordPress.com

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

Gambar Twitter

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

Foto Facebook

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

Foto Google+

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

Connecting to %s

Zoemalang's community

ujung malang adalah Sebuah desa yang hilang terganti dengan ujung harapan

YoYo Games Blog Feed

Ujung malang adalah Sebuah desa yang hilang terganti dengan ujung harapan

Dealer Termurah

Menjual Segala Jenis Motor Baru Di Indonesia Cash Maupun Kredit

%d blogger menyukai ini: