This Java tip explains the concept of how to implement a ticker in mobile handset. A ticker is an advertisement that runs across the top of the screen. It is basically an object that provides scrolling text across the top of the display. Further the ticker is associated with the display, not with the mobile screen.

 import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Ticker;

public class TickerDemo extends MIDlet implements CommandListener
{
  private Display display;
  private Command exit;
  Form frm;
  private Ticker ticker;
  
  public TickerDemo()
  {
    //Create a ticker with message
    ticker =new Ticker("Hello from JJKK");
     display = Display.getDisplay(this);  
   
  }
  public void startApp()
  {
    frm=new Form("Ticker Demo");
    exit= new Command("Exit",Command.EXIT,1);
    frm.addCommand(exit);
    frm.setCommandListener(this);
    //add ticker to displayable
    frm.setTicker(ticker);
    
    frm.append("#####");
    display.setCurrent(frm);
  }
  public void pauseApp()
  {
    
  }
  public void destroyApp(boolean un)
  {
  }
  public void commandAction(Command cmd,Displayable d)
  {
  
    if(cmd==exit)
    {
    
      
    }
  }
  
}

 

 

 Related Tips