从Javafx

时间:2017-11-16 22:22:31

标签: javafx

OverrunStyle.LEADING_ELLIPSIS类似,我想从单词start开始,但没有省略号,类似于ovverun样式剪辑。这可能吗?

2 个答案:

答案 0 :(得分:1)

您可以使用Label.setEllipsisString()

Label myLabel = new Label("SomeLongText");
myLabel.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS);
myLabel.setEllipsisString("");

这应该只根据需要截断文本,而不附加额外的字符(...)。

答案 1 :(得分:-1)

如果您正在寻找在fx标签之外使用的东西等,StringUtils可能会提供帮助

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#abbreviate-java.lang.String-int-

 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"