Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of Title Bar in framework "JAVAFX“?

Tags:

javafx

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.

enter image description here

like image 235
Scrovor Avatar asked Mar 03 '17 16:03

Scrovor


1 Answers

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.

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.

You can find an example implementation of that here: https://stackoverflow.com/a/9864496/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

like image 142
Spencer D Avatar answered Oct 07 '22 06:10

Spencer D