views:

133

answers:

1

im new to blackberry,So Please give a blackberry code for adding ticker to blackberry display bottom part of the disply ??

Need Only for how to Create a Ticker.??

Thank you

+1  A: 

try this

import java.util.Timer;
import java.util.TimerTask;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;

public class Ticker extends Field {

    String text;
    final int screenWidth = Display.getWidth();
    int offset = screenWidth;
    Timer timer = new Timer();
    final int delay = 30;

    public void setText(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    Ticker(String text) {
        this.text = text;
        final int width = Font.getDefault().getAdvance(text);
        TimerTask timerTask = new TimerTask() {
            public void run() {
                offset--;
                if (offset + width == 0) {
                    offset = screenWidth;
                }
                invalidate();
            }
        };
        timer.scheduleAtFixedRate(timerTask, delay, delay);
    }

    protected void layout(int width, int height) {
        int w = Display.getWidth();
        int h = Font.getDefault().getHeight();
        setExtent(w, h);

    }

    protected void paint(Graphics graphics) {
        graphics.drawText(text, offset, 0);
    }


}
Vivart
Hay..Thankz A Lot For Your help.How Can I Get Output from it? please..Help me it to..Im new To blackberry that is why i ask from each and every thing.Thank You
Gayan J
it means that how can i added to to my display.because ticker is not A field
Gayan J