应用程序启动时,Javafx删除快速白屏 [英] Javafx remove quick white screen on app start

查看:469
本文介绍了应用程序启动时,Javafx删除快速白屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用javafx 7更新60.
操作系统:Windows 7。

Using javafx 7 update 60. OS: Windows 7.

我刚刚从那里获取helloworld
http://docs.oracle.com/javafx/2/get_started/hello_world.htm

I've just taken helloworld from there http://docs.oracle.com/javafx/2/get_started/hello_world.htm

并将根窗格的背景更改为红色。

and changed background of root pane to red.

package sample;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloWorld extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.setStyle("-fx-background-color: #ff0000;");
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
}

当窗口出现时,我可以看到它背景是白色的,片刻后切换为红色。如何删除此白屏?

And while window is showing up, I can see its background is white, and after a moment switches to red. How can I remove this white screen ?

推荐答案

好的,您所看到的是实际的舞台背景。 primaryStage拥有自己的白色背景,您可以在加载场景之前看到它。除非你将舞台的背景设置为透明,但这也使得整个舞台透明,包括退出按钮,所以你必须有办法让用户退出程序。

Okay so what you're seeing is the actual stage background. The primaryStage has it's own white background which you are seeing a split second before the scene is loaded. There's no real way around this unless you set the stage's background to transparent but that also makes the entire stage transparent including the exit button so you have to have a way for the user to exit your program.

这篇关于应用程序启动时,Javafx删除快速白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆