JApplet 中的 JWindow
我想询问有关此问题的更多信息和建议。
我正在制作一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我和我的同事已经解决了这个问题。嗯,已经发现这条线
做了这个问题。在小程序中使用线程是不安全的(我猜)。这就是为什么建议如果您要在小程序中使用线程,请确保实例化一个线程,并且将使用该实例化的线程,而不是小程序中其他正在运行的线程。感谢 ultrajohn 的帮助!
Me and my colleague already solved this issue. Well, it has been discovered that the line
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!