首页 > 解决方案 > JavaFX 标签文本未显示

问题描述

我正在关注一本 JavaFX 书籍和其中一个在窗口中显示文本的示例,但窗口中没有显示文本。请帮忙。

        package sample;
        import javafx.application.Application;
        import javafx.fxml.FXMLLoader;
        import javafx.scene.Parent;
        import javafx.scene.Scene;
        import javafx.scene.layout.*;
        import javafx.scene.control.*;
        import javafx.scene.layout.FlowPane;
        import javafx.stage.Stage;

public class Main extends Application {



    public static void main(String[] args) {

        launch(args);
    }


    public void start(Stage myStage){

        myStage.setTitle("Demonstrate a Simple Scene Graph");
        FlowPane rootNode = new FlowPane();
        Scene myScene = new Scene (rootNode,500,500);
        myStage.setScene(myScene);
        Label myLabel = new Label ("A simple JavaFX label.");
        rootNode.getChildren().add(myLabel);
        myStage.show();
    }
}

我正在使用带有项目 SDK 10 和项目语言 10 的 intelij。

先感谢您!

2018 年 7 月 29 日更新。设法解决了问题。只需在 VM 选项中输入不包括双引号的“-Dprism.order=sw”。

我在这里找到了解决方案:https ://www.reddit.com/r/javahelp/comments/84w6i6/problem_displaying_anything_with_javafx_only/

标签: javajavafx

解决方案


推荐阅读