Java Reference
In-Depth Information
Listing 7-4. A MIDlet That Demonstrates StationSign
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class StationSignMIDlet
extends MIDlet
implements CommandListener {
public void startApp() {
Display display = Display.getDisplay(this);
Form form = new Form("StationSignMIDlet");
form.append(new StringItem("StringItem: ", "this is the first item "));
StationSign ss = new StationSign("Destination", display);
ss.add("Albuquerque");
ss.add("Savannah");
ss.add("Pocatello");
ss.add("Des Moines");
form.append(ss);
form.append(new StringItem("StringItem: ", "this is item two"));
Command c = new Command("Exit", Command.EXIT, 0);
form.addCommand(c);
form.setCommandListener(this);
display.setCurrent(form);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if (c.getCommandType() == Command.EXIT)
notifyDestroyed();
}
}
The MIDlet in action appears in Figure 7-4. The figure shows an instance of StationSign
sandwiched between two StringItem s. You can navigate through the form to see how the
appearance of StationSign changes when it has input focus. If you click the select button on
StationSign , you'll see the next choice scroll into view.
Search WWH ::




Custom Search