Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

changing the color of the text in a Menu control with CSS

922086Jun 16 2012 — edited Jun 16 2012
I want to change the text color of the Menu control in JavaFX. When I create a MenuBar in Scene Builder - it comes with 3 Menu controls by default ("*File*", "*Options*", "*Help*"). I have tried assigning a separate CSS id for each Menu control and using various combinations of properties to influence the text color, but can't seem to get it right whatsoever. What I want to achieve is, i.e., display *"File*" in black, instead of default white.

FXML here:
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
  <children>
    <MenuBar id="modBar" layoutX="176.0" layoutY="122.0" styleClass="modBar">
      <menus>
        <Menu id="modItem" mnemonicParsing="false" styleClass="modItem" text="File" />
      </menus>
      <stylesheets>
        <URL value="test.css" />
      </stylesheets>
    </MenuBar>
  </children>
</AnchorPane>
CSS here:
.modBar
{
    -fx-background-color: white;
}
.modItem
{
    -fx-color: black;
}
I have also tried extracting the caspian CSS and playing with various properties related to *.menu* and *.menu-bar*, but still can't see the one responsible for the color of the text in menu controls?

Any help would be greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2012
Added on Jun 16 2012
1 comment
5,950 views