java - 为什么我的 javafx 应用程序中缺少标题栏?
问题描述
公共类你好扩展应用程序{
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("hellofxml.fxml"));
Scene scene = new Scene(root,500,500);
stage.setScene(scene);
stage.setTitle("hello world");
// stage.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
public static void main(String[] args) {
launch(args);
System.out.println("hello");
}
}
这段代码的输出给了我一个没有任何关闭、最小化、最大化按钮的简单窗口,换句话说就是一个无标题窗口
我想知道问题出在哪里
图片链接是
https://ibb.co/5YNfR1G https://ibb.co/Hq9pM0S
fxml 代码
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1" fx:controller="Hello.HellofxmlController">
<children>
<Button fx:id="ok_btn" layoutX="238.0" layoutY="174.0" mnemonicParsing="false" text="ok" />
</children>
</AnchorPane>
解决方案
这是 GTK3 和 JavaFX 的一个已知问题,已在此处回答
推荐阅读
- c++ - Qt 子目录,其中一个项目生成另一个项目中使用的源/头文件
- javascript - 无法使用 addEventListener 将值传递给外部 JS 文件
- ios - 如何在 Apple Store 中添加顶部图像?
- sql-server - 从 SQL Server 到 Excel 的不同日期时间格式
- batch-file - 如何使用 vbs 运行多个批处理并使用环境变量设置批处理文件路径?
- sql-server - 如何向 T_SQL 存储过程添加可选参数?
- javascript - React.js this2.setState 不是函数?
- r - div容器中的脚本
- node.js - 从基于文件夹的 npm 依赖项导入模块
- javascript - 如何在点列表中附加光滑的箭头?