Ticker sample program in J2ME

By: Manoj Kumar  

A ticker is an object that provides scrolling text across the top of the display. A Ticker is associated with the display, not with the screen. You place a Ticker on a screen using the Screen.setTicker(Ticker t) method, as shown in the code below.

You can associate the same Ticker object with multiple screens, however. The implementation renders the Ticker on some constant portion of the display, in this case at the top of the display.  Ticker is not an Item. Its derivation directly from java.lang.Object gives you a clue as to why a Ticker can be tied to the display and not to a screen. It doesn't need to be derived from Item, because it really is not something that is placed in a Form.



// Ticker demo source code
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Ticker;
import javax.microedition.lcdui.Form;
This class demonstrates use of the Ticker MIDP UI
component class.
@see javax.microedition.lcdui.Gauge
public class TickerDemo extends Form
implements CommandListener
private String str =
"This text keeps scrolling until the demo stops...";
private Ticker ticker = new Ticker(str);
private Command back = new Command("Back", Command.BACK, 1);
private static Displayable instance;
public TickerDemo()
super("Ticker demo");
instance = this;



Archived Comments

1. thanks for the definition...more power :)
View Tutorial          By: saluki at 2011-07-19 05:36:00

2. It worked. Thank U!
View Tutorial          By: Abhijit Kurane at 2010-12-27 11:01:48

3. thanks i am fresher to j2me i understand the concept really thanks
View Tutorial          By: anusha at 2010-04-20 00:32:10

4. Thanks !
View Tutorial          By: Swaran at 2010-02-02 23:50:13

Most Viewed Articles (in J2ME )

Latest Articles (in J2ME)

Comment on this tutorial