Button and ToggleButton: Threat Unicode surrogate character pair as single character and make button square (issue #234)

This commit is contained in:
Karl Tauber
2021-01-09 23:46:56 +01:00
parent 1d06a2c2e8
commit 7d48bf06fe
4 changed files with 55 additions and 21 deletions

View File

@@ -251,7 +251,10 @@ public class FlatButtonUI
Icon icon = ((AbstractButton)c).getIcon();
String text = ((AbstractButton)c).getText();
return (icon != null && (text == null || text.isEmpty())) ||
(icon == null && text != null && ("...".equals( text ) || text.length() == 1));
(icon == null && text != null &&
("...".equals( text ) ||
text.length() == 1 ||
(text.length() == 2 && Character.isSurrogatePair( text.charAt( 0 ), text.charAt( 1 ) ))));
}
static final int TYPE_OTHER = -1;