Programming Tutorials

Ticker sample program in J2ME

By: Manoj Kumar in J2ME Tutorials on 2007-09-16  

A Ticker in J2ME is a scrolling text element that can be used to display a message, notification or a simple text string on the screen. It is often used to display a short message or alert to the user, such as a breaking news headline or a system message.

Here's an example program that demonstrates the use of Ticker in J2ME:

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

public class TickerExample extends MIDlet {

    private Display display;
    private Form form;
    private Ticker ticker;

    public TickerExample() {
        display = Display.getDisplay(this);
        form = new Form("Ticker Example");
        ticker = new Ticker("This is a scrolling text message.");
        form.setTicker(ticker);
        display.setCurrent(form);
    }

    protected void startApp() throws MIDletStateChangeException {
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    }
}

In this example, we create a new Form and set its title to "Ticker Example". We also create a Ticker object with the message "This is a scrolling text message." and set it as the ticker for the Form using the setTicker() method. Finally, we display the Form using the Display.setCurrent() method.

When the program is run, the Form is displayed with the Ticker scrolling the message across the screen.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in J2ME )

Latest Articles (in J2ME)