Search code examples
blackberryhorizontal-scrollinglabelfield

TextField horizontal-scrolling


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


Solution

  • 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.