我正在尝试为一个游戏制作闪屏,它们都是JFrames。我想让飞溅屏幕打开3秒钟,然后处理。游戏主要部分的JFrame需要立即创建并显示。我使用Thread.sleep()等待3秒,但加载页面延迟3秒而不是游戏。代码如下:如何解决此代码的闪屏?
new load();
try
{
Thread.sleep(3000);
dispose();
new gameInfo();
}
catch (InterruptedException ex)
{
Logger.getLogger(home.class.getName()).log(Level.SEVERE, null, ex);
}
我们需要更多的上下文。 “dispose”究竟做了什么,构造'load'和'gameInfo'对象的副作用是什么? –
为什么不使用Java的SplashScreen? https://docs.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html – Alanmars