如何在框架“JAVAFX”中更改标题栏的颜色? [英] How to change the color of Title Bar in framework "JAVAFX“?

查看:831
本文介绍了如何在框架“JAVAFX”中更改标题栏的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaFX的初学者。反正有没有改变标题栏的颜色。我只想让应用程序全黑。我搜索过JavaFX API,但是我找不到任何方法来实现它。

I'm a beginner of JavaFX. Is there anyway to change the color of title bar. I just want to make the application all black. I have searched the JavaFX API, but I can't find any method to make it.

推荐答案

这几乎与操作系统有关。默认情况下,操作系统决定如何显示标题栏和边框。但是,如果你愿意冒险制作自己的标题栏,肯定可以做到。

This is pretty much an OS dependent thing. The operating system gets to decide how titlebars and borders are displayed by default. However, it definitely can be done, if you are willing to venture into making your own title bar.

首先,你需要将应用程序窗口的阶段修改为 StageStyle.UNDECORATED 。然后,您需要设置自己的边框和标题栏(包括标题,最小化按钮,关闭按钮等)。然后,您可以将边框窗格作为场景添加到应用程序的舞台中,然后应该渲染自定义标题栏,而不使用默认的Windows样式。

To start out, you will need to modify the application window's stage to StageStyle.UNDECORATED. Then you will need to set up your own borders and title bar (complete with things like the title, minimize button, close button, etc.). You can then add the border pane as a scene into your application's stage, and that should render your custom titlebar then without the default Windows styling.

您可以找到示例实现其中: https://stackoverflow.com/a/9864496/2694511

You can find an example implementation of that here: https://stackoverflow.com/a/9864496/2694511

请注意,因为您正在实现自己的标题栏,所以您还将失去操作系统的默认窗口拖动行为,因此您需要实现自己的窗口拖动/窗口移动代码。这个答案可能会帮助你: https://stackoverflow.com/a/11781291/2694511

Do note that because you are implementing your own titlebar, you will also lose the OS's default window drag behavior, so you will need to implement your own window-drag/window-move code. This answer might be able to help you with that: https://stackoverflow.com/a/11781291/2694511

这篇关于如何在框架“JAVAFX”中更改标题栏的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆