Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFx未正确呈现_Java_User Interface_Javafx_Render - Fatal编程技术网

JavaFx未正确呈现

JavaFx未正确呈现,java,user-interface,javafx,render,Java,User Interface,Javafx,Render,我的代码由两个类组成,一个是MainGUI.java,另一个是Screen.java 我打算为不同的屏幕制作不同的类,并在需要时渲染它们 这是我为MainGUI.java提供的当前代码 import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.stage.Stage; public class MainGUI extends

我的代码由两个类组成,一个是MainGUI.java,另一个是Screen.java 我打算为不同的屏幕制作不同的类,并在需要时渲染它们

这是我为MainGUI.java提供的当前代码

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;


public class MainGUI extends Application{

    public static void main(String[] args) {
        launch(args);

    }

    @Override
    public void start(Stage pStage) throws Exception {

        Screen firstScreen = new Screen();
        Scene mainScene = new Scene(firstScreen );
        pStage.setScene(mainScene);
        pStage.setTitle("TestProg");
        pStage.show();
    }
}
这是Screen.java的代码

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;



public class Screen extends VBox{
    private final Label L1 = new Label("Label 1");
    private final Label L2 = new Label("Label 2");
    private final TextField F1 = new TextField();
    private final TextField F2 = new TextField();
    private final Button B1 = new Button("This is a button");

    Screen(){
        super();
        showStuff();
    }
    private void showStuff(){
        this.setSpacing(5);
        this.setAlignment(Pos.CENTER);
        this.setPadding(new Insets(10,0,0,10));
        HBox Box1 = new HBox(L1,F1);
        HBox Box2 = new HBox(L2,F2);
        this.getChildren().addAll(Box1,Box2,B1);
    }
}
以下是运行代码后得到的GUI屏幕截图:

我不知道哪些信息会有所帮助,但我正在使用jre1.8.0_25


从图像中可以看出,表单没有正确显示文本,下面还有一个灰色矩形。

用户报告说,通过命令行选项绕过硬件渲染管道修复了系统上的问题:

-Dprism.order=sw
请注意(从Java8开始),上述命令行开关是Oracle JavaFX运行时的一个未记录且不受支持的功能

见:



我以前在StackOverflow上看到过JavaFX应用程序的类似图片(尽管我找不到重复的问题)。我无法复制这些图像,也不知道它们的确切原因。该应用程序可能运行在JavaFX不支持的过时视频卡或视频卡驱动程序上

在我的电脑上运行良好,相同的jre+Win7.jre1.8.0_20-适合我。有什么问题?窗口的大小或这些奇怪的工件?工件,在我调整大小后,我无法在表单中输入更多的文本。@jewelsea你的链接成功了,我只需添加“-Dprism.order=sw”,如果你能包含你的答案,我可以给它打分的话。非常感谢。期望它能在javafx12和JDK11上工作,真相令人伤心。