2

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

Philayyy
  • 1,767
  • 4
  • 16
  • 22
  • `scene.setFill()` does the work – guleryuz Oct 09 '16 at 08:51
  • You have to set the stage initStyle to undecorated,then create the Basic Layout of your app.Lets assume using a BorderPane and in the top create the element you have in the image.The default header of the Stage is OS dependent,so you have to create your own.If you have a difficulty doing the above,a more detailed answer can be provided. – GOXR3PLUS Oct 09 '16 at 13:49

2 Answers2

0

I've found this link, does this help?

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

Varin
  • 2,354
  • 2
  • 20
  • 37
  • Thank you but I'm more so looking for a way to set the colour of the stage header rather than the actual scene that goes inside the stage – Philayyy Oct 09 '16 at 08:51
  • 1
    then you should find [this](http://stackoverflow.com/questions/11839199/custom-title-bar-in-javafx-2-0) and [this](http://stackoverflow.com/questions/11780115/moving-an-undecorated-stage-in-javafx-2) useful – guleryuz Oct 09 '16 at 08:54
-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

Strs
  • 5
  • 2