음표를 통해 항아리에 스플래시 화면을 간단하게 추가 할 수 있습니다.
기본적으로 문제는 스윙 앱이로드되는 동안 만 표시됩니다. 따라서 2 차 (3 번째 등) 실행은 JVM으로 스플래시 화면을 빠르게 표시하고 GUI에서 사용하는 클래스 등이 이미로드되었습니다.
/**
* This will render the splash for longer than just loading components
*
* @return true if there is a splash screen file supplied (set via java or
* manifest) or false if not
* @throws IllegalStateException
*/
private boolean showSplash() throws IllegalStateException {
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash == null) {
return false;
}
Graphics2D g = splash.createGraphics();
if (g == null) {
return false;
}
for (int i = 0; i < 100; i++) {//loop 100 times and sleep 50 thus 100x50=5000milis=5seconds
renderSplashFrame(g);
splash.update();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
splash.close();
return true;
}
private void renderSplashFrame(Graphics2D g2d) {
//draw anyhting else here
}
같은 것을 호출 될 것이다 : 나는이 두 가지 방법이 있었다 이상 유지 스플래시를 만들기 위해 내 게임에서
는 showSplash()
가 반환됩니다 말한대로
JFrame frame=...;
...
//show splash
if (!showSplash()) {
JOptionPane.showMessageDialog(null, "SplashScreen could not be shown!", "Splash Error: 0x003", JOptionPane.ERROR_MESSAGE);
}
// set JFrame visible
frame.setVisible(true);
frame.toFront();
있습니다 스플래시 스크린이 제공되지 않으면 (즉, 매니페스트에 추가하지 않은 경우) false입니다.
이미 havent 한 경우 How to Create a Splash Screen에 대한 읽기를 권장합니다. 그것을 설명 Make splash screen with progress bar like Eclipse
는 관련 코드를 게시하시기 바랍니다보다는 일반 텍스트 :
또한이 다른 유사한 대답/질문을 참조하십시오. –