Java Reference
In-Depth Information
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
// empty implementation, as there are no resources to be released
} protected void pauseApp() {
// empty implementation, as there are no resources to be released
All of our instance variables, references to the UI components in our
application, are declared and initialized to NULL . In the class construc-
tor, we assign each variable to a newly-created object of the proper
class. First, we create a couple of commands (Back and Exit) that will
be used to handle the high-level user actions defined by the device
implementation, assigned to the UI components and passed to us via the
commandAction(Command, Displayable) method:
backCommand = new Command("Back",Command.BACK,0);
exitCommand = new Command("Exit",Command.EXIT,0);
Following this, we begin to create the actual UI components. For
example, let's see how a new Form object is constructed:
form = new Form("My Form");
textField = new TextField("MyTextField","",20,TextField.ANY);
dateField = new DateField("MyDateField",DateField.DATE_TIME);
stringItem = new StringItem("MyStringItem","My value");
choiceGroup = new ChoiceGroup("MyChoiceGroup",Choice.MULTIPLE,
new String[] { "Value 1","Value 2","Value 3" } , null);
image = Image.createImage("/test.png");
imageItem = new ImageItem("MyImage",image,ImageItem.LAYOUT_CENTER,
"No Images");
gauge = new Gauge("My Gauge",true,100,1);
As outlined before, a Form is a flexible UI component that can hold
other components, instances of the Item class, and show them on the
screen. Users expect Form components to present information that is
related in meaning, such as settings for an application. Doing otherwise
can be confusing and result in bad user interaction with the application.
After instantiating a Form , we create its items ( textField , date-
Field , stringItem , choiceGroup , imageItem and Gauge ) and use
Search WWH ::

Custom Search