3 Replies Latest reply on Nov 22, 2008 7:06 AM by 843851

    Scroll Text like Stock bar

      hi guys,

      i am new in javatv development and i am stuck a little in this issue

      any one know how to scroll text on screen like the stock or news bar that we see on TV
      i tried regular java code but it stopped the application cause the thread may be.

      please can some one help or give hints i am using HText

      thanks in advance
        • 1. Re: Scroll Text like Stock bar
          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.
          • 2. Re: Scroll Text like Stock bar
            Also, if you wish to display icons, which some stock tickers display, you'll need to use something more complex than a simple drawString().
            • 3. Re: Scroll Text like Stock bar
              Thanks Imagist
              i will try to do it and i will give u the result

              thanks a lot