java - 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/
解决方案
推荐阅读
- excel - VBA Outlook 邮件正文不显示(可能是由于表格通过 vba excel 粘贴到邮件正文中)
- flutter - Flutter:[Cloud_firestore] 发布模式下没有数据
- android - 关于APK安装后生成的文件的权限问题
- macos - Minikube 访问使用注册表插件添加的图像
- mediawiki - MediaWiki:导入的模板返回许多错误
- mongodb - Spring boot + mongoDB 通过枚举过滤
- javascript - 通过来自前端的查询数据来识别用户的最佳实践是什么?
- python - 将函数应用于列表和数据框
- java - Spring Boot 异步任务卡在关机状态
- excel - excel中的动态/自动填充行