与OverrunStyle.LEADING_ELLIPSIS
类似,我想从单词start开始,但没有省略号,类似于ovverun样式剪辑。这可能吗?
答案 0 :(得分:1)
您可以使用Label.setEllipsisString():
Label myLabel = new Label("SomeLongText");
myLabel.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS);
myLabel.setEllipsisString("");
这应该只根据需要截断文本,而不附加额外的字符(...)。
答案 1 :(得分:-1)
如果您正在寻找在fx标签之外使用的东西等,StringUtils可能会提供帮助
StringUtils.abbreviate(null, *, *) = null
StringUtils.abbreviate("", 0, 4) = ""
StringUtils.abbreviate("abcdefghijklmno", -1, 10) = "abcdefg..."
StringUtils.abbreviate("abcdefghijklmno", 0, 10) = "abcdefg..."
StringUtils.abbreviate("abcdefghijklmno", 1, 10) = "abcdefg..."
StringUtils.abbreviate("abcdefghijklmno", 4, 10) = "abcdefg..."
StringUtils.abbreviate("abcdefghijklmno", 5, 10) = "...fghi..."
StringUtils.abbreviate("abcdefghijklmno", 6, 10) = "...ghij..."
StringUtils.abbreviate("abcdefghijklmno", 8, 10) = "...ijklmno"
StringUtils.abbreviate("abcdefghijklmno", 10, 10) = "...ijklmno"
StringUtils.abbreviate("abcdefghijklmno", 12, 10) = "...ijklmno"