JApplet 中的 JWindow

发布于 2024-08-24 02:20:12 字数 926 浏览 3 评论 0原文

我想询问有关此问题的更多信息和建议。

我正在制作一个 JApplet,我想添加一个闪屏。我用的是JWindow。在JWindow中我放置了一个JLabel...只是一个简单的标签,以便知道该标签是否会出现在JWindow中。不幸的是,jlabel 没有出现。我尝试将它作为一个简单的应用程序,并且它有效。这是我的启动画面代码。 `

尝试{
     javax.swing.JWindow 窗口 = new javax.swing.JWindow();       window.setBackground(Color.YELLOW);
      window.setLayout(new FlowLayout());
     window.add(new JLabel("twintwins"));
      window.setSize(200, 200);
     window.setVisible(true);
      Thread.sleep(5000);
      window.dispose();
}
catch(异常错误){
     JOptionPane.showMessageDialog(null, err.toString());
}`

请帮忙。谢谢。

i would like to ask for further information and suggestion about this problem.

I am making an JApplet and I want to put a splash screen. I used JWindow. In the JWindow I put a JLabel...just a simple label so as to know if the label would appear in the JWindow. Unfortunately, the jlabel did not appear. I tried it as a simple application and it works. Here is my code for the splash screen. `

try{
       javax.swing.JWindow window = new javax.swing.JWindow();
       window.setBackground(Color.YELLOW);
       window.setLayout(new FlowLayout());
       window.add(new JLabel("twintwins"));
       window.setSize(200, 200);
       window.setVisible(true);
       Thread.sleep(5000);
       window.dispose();
}

catch(Exception err){
       JOptionPane.showMessageDialog(null, err.toString());

}`

Please help. Thanks.

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

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

发布评论

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

评论(1

梦冥 2024-08-31 02:20:12

我和我的同事已经解决了这个问题。嗯,已经发现这条线

Thread.sleep(5000);

做了这个问题。在小程序中使用线程是不安全的(我猜)。这就是为什么建议如果您要在小程序中使用线程,请确保实例化一个线程,并且将使用该实例化的线程,而不是小程序中其他正在运行的线程。感谢 ultrajohn 的帮助!

Me and my colleague already solved this issue. Well, it has been discovered that the line

Thread.sleep(5000);

did the problem. It is unsafe to use threads in applets (I guess). That is why it is recommended that if you will use threads in applets, make sure to instantiate a thread and that instantiated thread will be used and not other running threads in your applet. Thanks ultrajohn for helping!

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