Search code examples
cssjavafxwindow

JavaFX - Where is the css file for definition of StageStyle located or how can I change it?


Problem:

I'm actually implementing some Frontend applications in JavaFX. There we're using several windows. In some cases the design of the windows have to be adapted like we want. That means it needs a specific icon, colour of the title and given images which replace the standard buttons for resizing, minimizing and closing the window. Consequently I have to adjust the whole title of the window.

What I have:

It is no problem to set a new icon, but the rest of the adaptions lead to problems. During my researches I found, that it is possible to define the StageStyle within my programm with the help of:

primaryStage.initStyle(StageStyle.DECORATED);

Possible solution:

I know that a possible solution for my problem is, to set the StageStyle on Undecorated and to adding a node which contains the necessary icons, button etc (like it was done here: https://gist.github.com/JaDogg/4d9999ba233f4a43b7c5). This can be the root of my window.

What I need:

The problem with the possible solution is, that it is hard to define the border in the same way like it is done within StageStyle.DECORATED. But it is recommand that the border of the windows with our own icons, buttons etc have to be similiar to the borders of the standard windows. That's why I have the idea to adjust the element which was defined within the StageStyle. But the problem is, that I don't know the name of it. If I use .root within my css file just my root scene is taken. But I need the whole window.

Does anybody know how the element is defined? Or does anybody know the location of the css file where the StageStyles are defined?

If I got it, I also know the name of the element. In addition to this as soon as I have the css declaration it is obvious how to configure my own window to get the same border like in the standard window of StageStyle.DECORATED.

Or perhaps does anybody know how to define the border so that it looks like the one of StageStyle.DECORATED?


Solution

  • Stage can be styled with a few options: decorated, undecorated, transparent, ..., while Scene can be fully styled with CSS. But there's no CSS for stage decoration.

    A good source to decorate an undecorated stage is this post.

    As you can see, its layer model will allow you to decorate the borders with CSS. But this will depend on the OS you're trying to mimic.

    For native implementations (mainly controls), have a look at these themes: AquaFX for Mac, AeroFX for Windows 7, or this one for Windows 8.