我正在嘗試爲一個遊戲製作閃屏,它們都是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