2

Hi i have implemented scrolling text horizontally through this link LabelField Marquee. But i have one problem,the text is scrolling quite good but its been over-written on the original text which was added.Can anyone have any idea how to cope from this problem? I also tried to refresh the view by invalidate() but of no use. i have added the screenshot of the problem which i am facing.

Any help would be appreciable.

Thank you.

enter image description here

Community
  • 1
  • 1
AkashG
  • 7,868
  • 3
  • 28
  • 43

2 Answers2

2

I would suggest you to change paint method to next:

 public void paint(Graphics graphics) {
    currentText = this.getText();
    if (currentChar < currentText.length()) {
        currentText = currentText.substring(currentChar);

    }
    graphics.drawText(currentText, 0, 0, DrawStyle.ELLIPSIS, 200);
}

So don't call super.paint() in your paint.

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
  • thankx @Eugen.Thankx a lot man :)..its my mistake i called super.paint() in my paint method. – AkashG Aug 20 '12 at 04:36
  • it work nice but it display test from middle to left, i want to do like, text should moving from right to left even text is Small or large. how i can do with this code can you help me please? – Hasmukh Nov 09 '12 at 11:13
  • Take a look in source code - set different font to label field and instead of starting from 0 position and move 4 symbols right on every tick, do start with text.length() and move 4 symbols left (change + operation to minus). If you still have questions - please create new topic – Eugen Martynov Nov 09 '12 at 12:28
1

I've rewritten (in a more simple way) the answer you linked. It works fine.

import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.DrawStyle;
import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class MyScreen extends MainScreen {

    public MyScreen() {

        super();

        MarqueeLabel testLabel2 = new MarqueeLabel("This is a long long " +
                "long long long long long long long long long long long " +
                "long long marquee", Field.FOCUSABLE);
        add(testLabel2);

    }

    class MarqueeLabel extends LabelField {

        // Here MarqueeLabel code from your SO linked example

    }

}
rosco
  • 939
  • 9
  • 16
  • i tried again this morning the way you said but the result is the same..its moving continuously but also over lapping the text...please get me rid out of this. – AkashG Aug 17 '12 at 05:01
  • I'm using JRE 5.0.0 on 8520 simulator. Java Plugin for Eclipse 1.3.0. Check your configuration. – rosco Aug 17 '12 at 06:58
  • rosco..its working fine in simulator but not working in device bold 9700 having os version 6.0 – AkashG Aug 17 '12 at 09:45