0

I have been trying to change the font of the menu, but no luck. I do not want the background to be white, but the font. This is my code: Can someone please help me?

// Add the menu items to the menu
        Menu menu = new Menu("Menu");
        menu.getItems().addAll(rulesItem, oddsItem, exitItem);
        menu.setStyle("-fx-font-size: 18; -fx-text-fill: white;");

I tried -fx-text-fill, but it doesn't work. I also tried setTextFill, but that doesn't work as well.

Mysterio
  • 1
  • 2
  • 1
    A menu item is composed of several components, one of which is the label. Take a look at [modena.css](https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css); search for ".menu-item". You'll have to override those css rules to achieve your desired results (i.e., redefine things like .menu-item > .label in your app's css file). – pfurbacher Mar 13 '23 at 19:42
  • [This](https://stackoverflow.com/questions/34682448/javafx-css-font-color-in-menuitem) or [this](https://forums.oracle.com/ords/apexds/post/using-custom-fonts-on-menubar-menu-and-or-menuitem-3447) may help. – SedJ601 Mar 27 '23 at 21:38

0 Answers0