如何在java应用程序中设置垂直选取框?

发布于 2024-09-04 20:03:38 字数 182 浏览 3 评论 0原文

我正在使用 swing 在 java 中创建一个应用程序。因为我有一个字符串数组,我尝试使用 html marquee 标签从上到下一一滚动所有字符串。但是 marquee 标签在面板中不支持。我怎样才能实现它。有人可以建议我吗? 提前致谢

I am creating 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

递刀给你 2024-09-11 20:03:38

我不相信 Swing 支持开箱即用的文本滚动。

这篇最近在 Free the Pixel 上发布的博客文章包含代码做一些漂亮的文字动画。它可能有用。

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.

落花随流水 2024-09-11 20:03:38

您可以通过使用线程编写自己的代码来做到这一点。

Marquee 类实现 Runnable
{
螺纹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);
        }
    }
} 

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);
        }
    }
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文