1. Create references.
2. Create a Display object.
3. Create an instance of the Command class to exit the MIDlet.
4. Call isColor() method.
5. Evaluate the return value of isColor() method.
6. Create an instance of the TextBox class that describes results of isColor()
method.
7. Associate the instances of the Command class with the instances of the
TextBox class.
8. Associate a CommandListener with the instance of the TextBox class.
9. Display the instance of the TextBox class on the screen.
10. Terminate the MIDlet when the Exit command is entered.
2. Create a Display object.
3. Create an instance of the Command class to exit the MIDlet.
4. Call isColor() method.
5. Evaluate the return value of isColor() method.
6. Create an instance of the TextBox class that describes results of isColor()
method.
7. Associate the instances of the Command class with the instances of the
TextBox class.
8. Associate a CommandListener with the instance of the TextBox class.
9. Display the instance of the TextBox class on the screen.
10. Terminate the MIDlet when the Exit command is entered.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CheckColor extends MIDlet implements CommandListener
private Display display;
private Form form;
private TextBox textbox;
private Command exit;
public CheckColor()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
String message=null;
if (display.isColor()) {
message="Color display.";
}
else
{
message="No color display";
}
textbox = new TextBox("Check Colors", message, 17, 0);
textbox.addCommand(exit);
textbox.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(textbox);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command command,
Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
}
}
import javax.microedition.lcdui.*;
public class CheckColor extends MIDlet implements CommandListener
private Display display;
private Form form;
private TextBox textbox;
private Command exit;
public CheckColor()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
String message=null;
if (display.isColor()) {
message="Color display.";
}
else
{
message="No color display";
}
textbox = new TextBox("Check Colors", message, 17, 0);
textbox.addCommand(exit);
textbox.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(textbox);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command command,
Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
}
}
No comments:
Post a Comment