首页 > 解决方案 > 无法在 javafx 程序上获得标题栏

问题描述

更新 java 8 jdk 适用于标题栏。这只是 java 11 jdk 的问题

我正在学习javafx。我从简单的应用程序开始,但我似乎无法获得标题栏。我正在使用linux(基本操作系统)。我试过stage.initStyle(StageStyle.DECORATED);了,我似乎找不到其他有这个问题的人。我只找到那些试图删除标题栏的人。可能是操作系统的问题?

我正在使用 jdk 11 和 javafx11

package sample;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application implements EventHandler<ActionEvent> {
    Button button;

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

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("title of window");
        button = new Button();
        button.setText("click me");

        StackPane layout = new StackPane();
        layout.getChildren().add(button);

        Scene scene = new Scene(layout, 300, 250);



        primaryStage.setScene(scene);
        primaryStage.show();
    }

    @Override
    public void handle(ActionEvent event) {

    }
}

在此处输入图像描述

标签: javauser-interfacejavafxjavafx-11

解决方案


推荐阅读