Java Reference
In-Depth Information
mModalAlert = new Alert("About TwoAlerts",
"TwoAlerts is a simple MIDlet that demonstrates the use of Alerts.",
null,
AlertType.INFO);
mModalAlert.setTimeout(Alert.FOREVER);
}
public void startApp() {
mDisplay = Display.getDisplay(this);
mDisplay.setCurrent(mTextBox);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if (c == mAboutCommand)
mDisplay.setCurrent(mModalAlert);
else if (c == mGoCommand)
mDisplay.setCurrent(mTimedAlert, mTextBox);
else if (c == mExitCommand)
notifyDestroyed();
}
}
Summary
MIDP's main user interface classes are based on abstractions that can be adapted to devices
that have different display and input capabilities. Several varieties of prepackaged screen
classes make it easy to create a user interface. Screens have a title and an optional ticker. Most
importantly, screens can contain Command s, which the implementation makes available to the
user. Your application can respond to commands by acting as a listener object. This chapter
described TextBox , a screen for accepting user input, and Alert , a simple screen for displaying
information. In the next chapter, we'll get into the more complex List and Form classes.
Search WWH ::




Custom Search