【问题标题】:Customizing primaryStage title : centered with icon自定义primaryStage标题:以图标为中心
【发布时间】:2019-04-15 19:53:14
【问题描述】:

我正在使用 Java FX 进行一个学校项目,我想在我的 primarystage 标题旁边添加一个图标并将标题居中,就像图片中的那个一样。我在 Stage 的 javadoc 中环顾四周,但只能找到 setTitle() 方法。这是我想做的事情的链接:

【问题讨论】:

标签: java javafx customization title stage


【解决方案1】:

您可以将舞台设置为未装饰,将场景根设置为边框窗格并创建自己的自定义顶栏。

BorderPane root = new BorderPane();
root.setTop(new Pane(bb, label));
Scene scene = new Scene(root, 400, 400);

ButtonBar topBar = new ButtonBar(… insert buttons in here....);
// eg: Button b = new Button("X); b.setOnAction(e->{stage.close();});
root.setTop(topBar);

stage.initStyle(StageStyle.UNDECORATED);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 2015-02-27
    • 1970-01-01
    • 2019-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多