【发布时间】:2016-02-14 17:41:31
【问题描述】:
我的预加载器中有这个:
import javafx.application.Preloader;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class SplashScreenView extends Preloader {
ProgressBar bar;
Stage stage;
// boolean noLoadingProgress = true;
public Scene createPreloaderScene()
{
bar = new ProgressBar();
BorderPane borderPane = new BorderPane();
borderPane.setCenter(bar);
return new Scene(borderPane, 500, 150);
}
public void start(Stage stage) throws Exception
{
this.stage = stage;
stage.setScene(createPreloaderScene());
stage.show();
}
@Override
public void handleStateChangeNotification(StateChangeNotification info)
{
if (info.getType() == StateChangeNotification.Type.BEFORE_START)
{
stage.hide();
}
}
@Override
public void handleProgressNotification(ProgressNotification pn)
{
bar.setProgress(pn.getProgress());
System.out.println("Progress " + bar.getProgress());
}
@Override
public void handleApplicationNotification(PreloaderNotification arg0)
{
if (arg0 instanceof ProgressNotification)
{
ProgressNotification pn = (ProgressNotification) arg0;
bar.setProgress(pn.getProgress());
System.out.println("Progress " + bar.getProgress());
}
}
}
这在我的主要应用程序中。
init (){
//loading images
}
public static void main(String[] args){
LauncherImpl.launchApplication(Main.class, SplashScreenView.class, args);
}
但progressBar 并不laod。相反,它首先是 0.0 ,然后是 1.0 ,所以 pregressBar 已经满了。但我必须等待几秒钟。在这几秒钟之后,我的主应用程序启动了......
请帮忙:(
【问题讨论】:
标签: java progress-bar javafx-8 splash-screen preloader