ADDITIONAL SYSTEM INFORMATION :
Windows 11 x64, OpenJDK 21.0.2
A DESCRIPTION OF THE PROBLEM :
When creating any labeled component that supports mnemonics, the mnemonics renders differently if there is also a `graphic` node in the component. It is unsure what the desired behaviour, but the bug is caused by the fact that we do not call `mnemonic_underscore.setStrokeWidth` if there is no `graphic` node.
Here it is not being set:
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L640
Here it is being set:
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L653
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L700
Judging by the code, it would appear that the cases where it is being set, are the correct cases. However, in that case the mnemonic does not only appear to thick, but also too wide, due to the antialising I assume.
I would propose to keep the visuals from the case that does not have a graphic.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start the Executable Test Case
2. Press Alt
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The mnemonic underscores should be of the same size, no matter whether a graphic node is present or not.
ACTUAL -
The case where a graphic node is present renders a slightly wider and slightly thicker mnemonic underscore.
---------- BEGIN SOURCE ----------
package com.example.javafx_mnemonic_bug;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
@Override
public void start(Stage stage) throws IOException {
final var buttonNoGraphic = new Button("_Hello");
buttonNoGraphic.setMnemonicParsing(true);
final var buttonGraphic = new Button("_Hello");
buttonGraphic.setMnemonicParsing(true);
buttonGraphic.setGraphic(new Label());
final var layout = new VBox(
buttonNoGraphic,
buttonGraphic
);
Scene scene = new Scene(layout, 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
We weren't able to find a workaround.
FREQUENCY : always
Windows 11 x64, OpenJDK 21.0.2
A DESCRIPTION OF THE PROBLEM :
When creating any labeled component that supports mnemonics, the mnemonics renders differently if there is also a `graphic` node in the component. It is unsure what the desired behaviour, but the bug is caused by the fact that we do not call `mnemonic_underscore.setStrokeWidth` if there is no `graphic` node.
Here it is not being set:
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L640
Here it is being set:
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L653
https://github.com/openjdk/jfx/blob/e3c15957488256ec53c5fb9978e336c59b69d65e/modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java#L700
Judging by the code, it would appear that the cases where it is being set, are the correct cases. However, in that case the mnemonic does not only appear to thick, but also too wide, due to the antialising I assume.
I would propose to keep the visuals from the case that does not have a graphic.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start the Executable Test Case
2. Press Alt
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The mnemonic underscores should be of the same size, no matter whether a graphic node is present or not.
ACTUAL -
The case where a graphic node is present renders a slightly wider and slightly thicker mnemonic underscore.
---------- BEGIN SOURCE ----------
package com.example.javafx_mnemonic_bug;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
@Override
public void start(Stage stage) throws IOException {
final var buttonNoGraphic = new Button("_Hello");
buttonNoGraphic.setMnemonicParsing(true);
final var buttonGraphic = new Button("_Hello");
buttonGraphic.setMnemonicParsing(true);
buttonGraphic.setGraphic(new Label());
final var layout = new VBox(
buttonNoGraphic,
buttonGraphic
);
Scene scene = new Scene(layout, 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
We weren't able to find a workaround.
FREQUENCY : always