首页 > 解决方案 > 为什么我的 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>

标签: javauser-interfacejavafx

解决方案


这是 GTK3 和 JavaFX 的一个已知问题,已在此处回答


推荐阅读