如何在JavaFX中创建自定义加载屏幕?

时间:2022-09-02 15:04:56

I'd like to create a custom loading screen for a JavaFX application. Don't want the user to see the Java coffee cup icon, I want to put my own graphic there!

我想为JavaFX应用程序创建一个自定义加载屏幕。不希望用户看到Java咖啡杯图标,我想在那里放置我自己的图形!

I've found out how to provide a static image, or even an animated GIF, but I'm more interested in a Flash-like screen where I can specify what the state of the image looks like at certain percentages.

我已经找到了如何提供静态图像,甚至是动画GIF,但我对类似Flash的屏幕更感兴趣,我可以指定图像的状态在某些百分比下的样子。

Any ideas?

4 个解决方案

#1


3  

For JavaFX2, you can set a custom preloader. You have complete control over then scene. I haven't used them personally, but this might be what you want. http://docs.oracle.com/javafx/2/deployment/preloaders.htm

对于JavaFX2,您可以设置自定义预加载器。您可以完全控制场景。我没有亲自使用它们,但这可能是你想要的。 http://docs.oracle.com/javafx/2/deployment/preloaders.htm

#2


2  

If you're setting things up as shown on This blog entry, it looks like the answer would be 'no' - the loading graphic is just part of the overall options that are passed to the applet. Because this applet could be any java code (not just javaFX), there's no way to tie your custom renderer in.

如果您按照此博客条目所示进行设置,则看起来答案为“否” - 加载图形只是传递给applet的整体选项的一部分。因为这个applet可以是任何java代码(不仅仅是javaFX),所以无法将自定义渲染器绑定。

#3


2  

you should use java timer:

你应该使用java计时器:

Timer tm= new Timer(); 
Stage ilk;
int count;

public  void check() {      

    ilk=new Stage();
    TimerTask mission;

    gorev = new TimerTask() {
        @Override
        public void run() {

            Group root = new Group();     

            Scene scene;
            scene = new Scene(root, 960, 540);
            scene.setFill(Color.BLACK);
            ilk.setScene(scene);
            ilk.setTitle("Splash Screen"); 

            sayac++;
            if(count==5){
                tm.cancel();
                ilk.show();  
            }
        }
    };
    tm.schedule(mission, 0, 2000);
}

#4


0  

For changing the coffee cup icon:

更换咖啡杯图标:

stage.getIcons().add(new Image("images/myimage.png"));

and here is a reference for a very clear preloader screen out there and awesome css too: http://docs.oracle.com/javafx/2/best_practices/jfxpub-best_practices.htm

这里有一个非常清晰的预加载器屏幕的参考,也有很棒的css:http://docs.oracle.com/javafx/2/best_practices/jfxpub-best_practices.htm

#1


3  

For JavaFX2, you can set a custom preloader. You have complete control over then scene. I haven't used them personally, but this might be what you want. http://docs.oracle.com/javafx/2/deployment/preloaders.htm

对于JavaFX2,您可以设置自定义预加载器。您可以完全控制场景。我没有亲自使用它们,但这可能是你想要的。 http://docs.oracle.com/javafx/2/deployment/preloaders.htm

#2


2  

If you're setting things up as shown on This blog entry, it looks like the answer would be 'no' - the loading graphic is just part of the overall options that are passed to the applet. Because this applet could be any java code (not just javaFX), there's no way to tie your custom renderer in.

如果您按照此博客条目所示进行设置,则看起来答案为“否” - 加载图形只是传递给applet的整体选项的一部分。因为这个applet可以是任何java代码(不仅仅是javaFX),所以无法将自定义渲染器绑定。

#3


2  

you should use java timer:

你应该使用java计时器:

Timer tm= new Timer(); 
Stage ilk;
int count;

public  void check() {      

    ilk=new Stage();
    TimerTask mission;

    gorev = new TimerTask() {
        @Override
        public void run() {

            Group root = new Group();     

            Scene scene;
            scene = new Scene(root, 960, 540);
            scene.setFill(Color.BLACK);
            ilk.setScene(scene);
            ilk.setTitle("Splash Screen"); 

            sayac++;
            if(count==5){
                tm.cancel();
                ilk.show();  
            }
        }
    };
    tm.schedule(mission, 0, 2000);
}

#4


0  

For changing the coffee cup icon:

更换咖啡杯图标:

stage.getIcons().add(new Image("images/myimage.png"));

and here is a reference for a very clear preloader screen out there and awesome css too: http://docs.oracle.com/javafx/2/best_practices/jfxpub-best_practices.htm

这里有一个非常清晰的预加载器屏幕的参考,也有很棒的css:http://docs.oracle.com/javafx/2/best_practices/jfxpub-best_practices.htm