This content has been marked as final. Show 3 replies
1. Create a component with a clip on the area in which you want the scrolling text to display.
2. Get the width of the string you wish to scroll using FontMetrics.
3. In the paint() and/or update() methods, use Graphics.drawString() to draw the string TWICE, once starting to the left of the component, and once at the right end of the first drawString() (using the width you got from FontMetrics). You draw twice to allow wraparound. With a very short string you might need to draw more than twice (if the string is narrower than your screen).
4. Set a thread to redraw the two strings farther and farther left each time. When the first drawString() is no longer on screen, move the first draw back to start drawing at the left of your component. The user won't see this jump because the first and second strings being drawn are identical, so it appears that the same string is looping with a constant leftward motion.
5. You may see flickering with each draw. If so, implement double buffering.
Also, if you wish to display icons, which some stock tickers display, you'll need to use something more complex than a simple drawString().
i will try to do it and i will give u the result
thanks a lot