开发者

how set vertical marquee in java application?

I am creating 开发者_StackOverflow社区one application in java using swing.In that i have an array of String, I try to use html marquee tag to scroll all the strings one by one from top to bottom.But the marquee tag doesn't support in the panel. How can i acheive it.Can any one suggest me? Thanks in advance


I don't believe Swing supports text scrolling out of the box.

This recent blog post at Free the Pixel has code to do some nice text animation. It might be useful.


u can do it by writing your own code using thread.

class Marquee implements Runnable { Thread t;

    Marquee()
    {
        t = new Thread(this, "Demo Thread");
        t.start();
    }
    public void run()
    {
        try
        {
            for(int i = 820; i>0 ;i-=5)
            {
                marql.setBounds(i,10,130,40);// marql label moves 
                Thread.sleep(500);
                p3.repaint(); //p3 is a panel with layout null 
                                    if(i<10)
                                    {
                                          i = 820;
                                     }

            }
        }
        catch(InterruptedException e)
        {
            System.out.println("Thread Interrupted "+e);
        }
    }
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜