'How to change the colour of the stage frame in javaFX?

Pretty straight forward from the title. Is there any way to do this? The default is white, but it conflicts with my applications colour scheme. I was aiming for a window such as Spotify's

And by window I mean the entire frame, see how the Icon in the top left-hand corner has the spotify logo and the background behind it's coloured? Same for the window controls on the left-hand side.

enter image description here



Solution 1:[1]

I've found this link, does this help?

http://www.java2s.com/Code/Java/JavaFX/SetScenebackgroundcolorandsize.htm

Solution 2:[2]

Try using css:

.menu-bar {
  -fx-background-color: derive(#FF1d1d,20%); // your color here
}

Example of Layout:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.input.*?>
<?import javafx.scene.layout.*?>

<BorderPane prefHeight="400.0" prefWidth="700.0" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.makery.address.view.RootLayoutController">
<top><MenuBar BorderPane.alignment="CENTER">
  <menus>
    <Menu mnemonicParsing="false" text="File">
      <items><MenuItem mnemonicParsing="false" onAction="#handleNew" text="New">
<accelerator>
<KeyCodeCombination alt="UP" code="N" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem><MenuItem mnemonicParsing="false" onAction="#handleOpen" text="Open...">
<accelerator>
<KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
        <MenuItem mnemonicParsing="false" onAction="#handleSave" text="Save">
<accelerator>
<KeyCodeCombination alt="UP" code="S" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
        <MenuItem mnemonicParsing="false" onAction="#handleSaveAs" text="Save As..." /><MenuItem mnemonicParsing="false" onAction="#handleExit" text="Exit" />
      </items>
    </Menu>
    <Menu mnemonicParsing="false" text="Statistics">
      <items>
        <MenuItem mnemonicParsing="false" onAction="#handleShowBirthdayStatistics" text="Show Statistics" />
      </items>
    </Menu>
    <Menu mnemonicParsing="false" text="Help">
      <items>
        <MenuItem mnemonicParsing="false" onAction="#handleAbout" text="About" />
      </items>
    </Menu>
  </menus>
</MenuBar>
</top></BorderPane>

Result

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Varin
Solution 2 Strs