This class represents the display manager and the input devices. As we mentioned before, every MIDlet has to have at least one Display object. This class can get information about the display of the device and is able to display every object that compounds our user interface.

If we go back to our first MIDlet, we can see the following line:

myDisplay = Display.getDisplay(this);

We have this line in the MIDlet constructor, which allow us to have this object available as long as the MIDlet is executed. We need to be sure that whenever our application is running we are setting the current display to an object that extends the Displayable class:

A Command object keeps information about an event; we can think of it a button which allows us to detect an action.

A Command object receives three parameters:

Label: the text that will be shown in screen that uses our Command.

Type: it is an identifier for the type of Command we want to create, the values are static finals from the Command class: BACK, CANCEL, EXIT, HELP, ITEM, OK, SCREEN, and STOP. This type will allow the device to render the Command object with a specific look and feel if possible.

Priority: this will give an order for the AMS for rendering different Command objects. The greater the value, the lower the priority.

So, to create a new Command we need to add a line like the following:

new Command("OK", Command.OK, 1);

In order for our MIDlet to be able to execute our Command objects, we need our MIDlet to implement the CommandListenerinterface, and by doing this we will need to implement the method: commandAction(Command c, Displayable d). In this method we will define which action to take when an event from the Command c in the object Displayable d is executed.