On Mon, 17 Aug 2026 20:45:32 GMT, Andy Goryachev <[email protected]> wrote:
> to keep the changes to a minimum
This is the key point.
The StringIndexOutOfBoundsException occurs because the ``mnemonicIndex`` is -1.
Since the ``mnemonicIndex`` is checked for being >= 0 in other places in
``javafx.scene.control.skin.LabeledSkinBase`` and
``com.sun.javafx.scene.control.skin.Util`` classes, I decided to move the
``updateDisplayedText()`` back behind the ``ignoreText`` condition and to add a
new ``mnemonicIndex >=0`` condition to the if-clause instead.
This avoids the error and minimizes the risk of regressions.
Point2D mnemonicPos = null;
double mnemonicWidth = 0.0;
double mnemonicHeight = 0.0;
int mnemonicIndex = mnemonicInfo != null ? mnemonicInfo.getMnemonicIndex() : -1;
if (containsMnemonic && mnemonicIndex >= 0) {
final Font font = text.getFont();
String preSt = mnemonicInfo.getText();
boolean isRTL = (labeledNode.getEffectiveNodeOrientation() ==
NodeOrientation.RIGHT_TO_LEFT);
mnemonicPos = Utils.computeMnemonicPosition(font, preSt, mnemonicIndex,
this.wrapWidth, labeled.getLineSpacing(), isRTL);
mnemonicWidth = Utils.computeTextWidth(font, preSt.substring(mnemonicIndex,
mnemonicIndex + 1), 0);
mnemonicHeight = Utils.computeTextHeight(font, "_", 0,
text.getBoundsType());
}
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2253#discussion_r3805347630