1

I have multiple buttons in in my javafx appliaction with mnemonics. When I press "Alt" the mnemonics appear in a dark color but I want them to be white.

What is the right css selector for this?

enter image description here

I tried:

.mnemonic-underline: {
  -fx-stroke: white;
}

But after that the underlines are visible all the time.

PrimosK
  • 13,848
  • 10
  • 60
  • 78
Philipp
  • 335
  • 1
  • 6
  • 17
  • 1
    https://openjfx.io/javadoc/15/javafx.graphics/javafx/scene/doc-files/cssref.html - if it's not there (and you find nothing in modena css nor the skin implementations, if you are allowed to go dirty) then it's not supported. – kleopatra Jan 15 '21 at 10:57

1 Answers1

3

This should work:

:show-mnemonics > .mnemonic-underline {
    -fx-stroke: white;
}

Example program:

public class MnemonicStylingSSCCE extends Application {

    @Override
    public void start(Stage stage) {
        // Init label
        final Label mnemonic = new Label("_Mnemonic");
        mnemonic.setMnemonicParsing(true);

        // Init scene
        final Scene scene = new Scene(mnemonic);
        scene.getStylesheets().add(MnemonicStylingSSCCE.class.getResource("mnemonic.css").toExternalForm());
        stage.setScene(scene);

        // Request focus & show
        stage.requestFocus();
        stage.show();
    }

}

Side note - the content of mnemonic.css is CSS shown above (but with the red color instead of white).

enter image description here

PrimosK
  • 13,848
  • 10
  • 60
  • 78