從標題上看很直接。有什么辦法可以做到這一點?默認是白色,但它與我的應用程序配色方案沖突。我的目標是像Spotify這樣的窗口
我說的窗口指的是整個框架,看到左上角的圖標有spotify的標志和它后面的彩色背景了嗎?左手邊的窗口控件也是如此。
我找到了這個鏈接,有幫助嗎?
http://www . Java 2s . com/Code/Java/Java FX/setscenebackgroundcolorandsize . htm
嘗試使用css:
.menu-bar {
-fx-background-color: derive(#FF1d1d,20%); // your color here
}
布局示例:
<?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>
結果