Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,15 @@ protected void layoutLabelInArea(double x, double y, double w, double h, Pos ali
graphicHeight = graphic.getLayoutBounds().getHeight();
}

// Have to do this just in case it needs to be recomputed
// This is especially important because it also recomputes the 'containsMnemonic' value,
// which is used by this method later on.
updateDisplayedText(w, h);

if (ignoreText) {
textWidth = textHeight = 0;
text.setText("");
} else {
updateDisplayedText(w, h); // Have to do this just in case it needs to be recomputed
textWidth = snapSizeX(Math.min(text.getLayoutBounds().getWidth(), wrapWidth));
textHeight = snapSizeY(Math.min(text.getLayoutBounds().getHeight(), wrapHeight));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,60 @@ public void testEscapedMnemonicSymbolIsNotProcessedWhenParsingIsDisabled() {
assertEquals("foo __bar", LabelSkinBaseShim.getText(label).getText());
}

@Test
public void testMnemonics_whenTextNotEmpty_noExceptionIsThrown() {
Toolkit tk = Toolkit.getToolkit();
StageLoader sl = new StageLoader(label);
tk.firePulse();

label.setMnemonicParsing(true);

label.setText("foo_bar");
tk.firePulse();
label.setText("xxx");
tk.firePulse();
label.setText("foo_bar");
tk.firePulse();

sl.dispose();
}

@Test
public void testMnemonics_whenTextIsEmpty_noExceptionIsThrown() {
Toolkit tk = Toolkit.getToolkit();
StageLoader sl = new StageLoader(label);
tk.firePulse();

label.setMnemonicParsing(true);

label.setText("foo_bar");
tk.firePulse();
label.setText("");
tk.firePulse();
label.setText("foo_bar");
tk.firePulse();

sl.dispose();
}

@Test
public void testMnemonics_whenTextIsNull_noExceptionIsThrown() {
Toolkit tk = Toolkit.getToolkit();
StageLoader sl = new StageLoader(label);
tk.firePulse();

label.setMnemonicParsing(true);

label.setText("foo_bar");
tk.firePulse();
label.setText(null);
tk.firePulse();
label.setText("foo_bar");
tk.firePulse();

sl.dispose();
}

/*********************************************************************
*
* Tests for bug reports *
Expand Down