내 JavaFX 프리 로더 스플래쉬 sccreen을 응용 프로그램 전에 표시하려고합니다. 이클립스 IDE를 사용하고 있는데 "실행"을 클릭하면 스플래시 화면이 올바르게 표시되는 시간의 절반과 이미지의 위치 대신 회색 또는 검은 색 화면이 표시되는 나머지 절반이 표시됩니다.JavaFX Preloader가 가끔씩 회색/검정색으로 표시되고 올바르게로드되는 경우가 있습니까?
가끔 올바르게 표시하는 것이 무엇이 문제인지 잘 모르겠습니다.
SplashController :
public class SplashController extends Preloader {
private static final double WIDTH = 676;
private static final double HEIGHT = 227;
private Stage preloaderStage;
private Label progressText;
private Pane splashScreen;
public SplashController() {}
@Override
public void init() throws Exception {
ImageView splash =
new ImageView(new Image(Demo.class.getResource("pic.png").toString()));
progressText =
new Label("VERSION: " + getVersion() + " ~~~ Loading plugins, please wait...");
splashScreen = new VBox();
splashScreen.getChildren().addAll(splash, progressText);
progressText.setAlignment(Pos.CENTER);
}
@Override
public void start(Stage primaryStage) throws Exception {
this.preloaderStage = primaryStage;
Scene splashScene = new Scene(splashScreen);
this.preloaderStage.initStyle(StageStyle.UNDECORATED);
final Rectangle2D bounds = Screen.getPrimary().getBounds();
this.preloaderStage.setScene(splashScene);
this.preloaderStage.setX(bounds.getMinX() + bounds.getWidth()/2 - WIDTH/2);
this.preloaderStage.setY(bounds.getMinY() + bounds.getHeight()/2 - HEIGHT/2);
this.preloaderStage.show();
}
}
그리고 내 메인 클래스에 데모는 단순히 있습니다
public class Demo extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new
FXMLLoader(Demo.class.getResource("FXMLDocument.fxml"));
GridPane root = loader.load();
--------other app code here---------
}
public static void main(String[] args) {
LauncherImpl.launchApplication(Demo.class, SplashController.class, args);
}
}
감사합니다! 예, 문제는 JavaFX 스레드에서 오랫동안 실행중인 프로세스였습니다. – chip
OK, 행운의 추측 :-), 방금 대답에 대한 설명을했습니다. – jewelsea