Is it a color cell phone : Display « J2ME « Java Tutorial






Is it a color cell phone
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;

public class J2MECheckColor extends MIDlet implements CommandListener {
  private Display display;

  private Form form;

  private TextBox textbox;

  private Command exit = new Command("Exit", Command.SCREEN, 1);

  public J2MECheckColor() {
    display = Display.getDisplay(this);
    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();
    }
  }
}








31.2.Display
31.2.1.Add TextBox to DisplayAdd TextBox to Display
31.2.2.Get color from DisplayGet color from Display
31.2.3.Is it a color cell phoneIs it a color cell phone