실제 응용 프로그램 창 열기 전에로드하는 창을 만드는 중입니다. 적재 장면에 progressBar가 있고 그것은 미정입니다.javaFx에서 응용 프로그램 창 앞에 장면로드하는 방법?
문제는 있습니다. progressbar는 프로그램을 실행할 때 실제 창이 열릴 때까지 작동하지 않습니다.
나는 preloader 클래스를 시도했지만, 역시 작동하지 않습니다.
여기 내 코드입니다.
public class MainApp2 extends Application {
private Stage loadingStage = new Stage();
public static void main(String[] args) {
launch(args);
}
public void start(final Stage mainStage) throws Exception {
//loading..
loadingScreen();
//start...
appScreen();
}
private void loadingScreen() {
ProgressBar bar = new ProgressBar(ProgressIndicator.INDETERMINATE_PROGRESS);
bar.setPrefWidth(300);
bar.setPrefHeight(200);
loadingStage.initStyle(StageStyle.TRANSPARENT);
loadingStage.initStyle(StageStyle.UNDECORATED);
loadingStage.setScene(new Scene(bar));
loadingStage.show();
}
private void appScreen() {
new Task<Void>() {
@Override
protected Void call() throws Exception {
Stage mainStage = new Stage();
//get real window
Scene root = new Scene(new MyAppWindow().getAppWindow());
mainStage.setScene(root);
mainStage.centerOnScreen();
mainStage.show();
// loadingStage.close();
return null;
}
}.run();
}
public class MyAppWindow {
public BorderPane getAppWindow(){
System.out.println("may be initialize take a long time...");
for (int i = 0; i < 90000000; i++) {
System.out.print("");
}
return new BorderPane(new Label("Here is real application Window!"));
}
}
}
감사합니다,하지만 나를 위해 작동하지 않으며, 당신의 프리 로더에 대한 제안에 대한 –
덕분에 다시, 나는 기사를 발견 왜 몰라 [HTTPS ://blog.codecentric.de/ko/2015/09/javafx-how-to-easily-implement-application-preloader-2/] 내 문제가 해결 될 것이라고 생각합니다. –