Use Ticker : Ticker « J2ME « Java Tutorial






Use Ticker
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.MIDlet;

public class J2MEappendTicker extends MIDlet implements CommandListener {
  private Command exitCommand  = new Command("cmd", Command.EXIT, 1);

  private Display display;

  public J2MEappendTicker() {
    display = Display.getDisplay(this);
  }

  public void startApp() {
    TextBox t = new TextBox("Hello", "Welcome to MIDP Programming", 256, 0);
    Ticker aTicker = new Ticker("ticker");
    t.setTicker(aTicker);
    t.addCommand(exitCommand);
    t.setCommandListener(this);
    display.setCurrent(t);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command c, Displayable s) {
    if (c == exitCommand) {
      destroyApp(false);
      notifyDestroyed();
    }
  }
}








31.10.Ticker
31.10.1.Use TickerUse Ticker