如何将没有空格的长文本换行

发布于 2024-09-14 15:23:22 字数 645 浏览 1 评论 0原文

final jLabel descLabel = new jLabel();
des.setWordWrap(true);
des.setWidth("200px");
descLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
tableDisplay.setWidget(row, 2, des);

我将标签放在 FlexTable 中,

这就是它在标签中的外观。它超出了我为标签指定的宽度。 显得很奇怪。我的意思是说,没有空格的长文本不遵循我为标签指定的宽度。尝试给出这个:

public class Jlabel extends Label{
public  Jlabel () {
 DOM.setStyleAttribute(this.getElement(), "word-wrap", "break-word");
}

wwwwwwwwwr ttttttttttt rrrrrrrrrrrrrrrrr yyyyyyyyyyyyyyyyr rriuoeggn ryyyyyy ryj klrtp;irptiml;rtkroitlrktrpotilr;gkawpeti;lrkgwptjkrotkw;'rtoi4p[tok

final jLabel descLabel = new jLabel();
des.setWordWrap(true);
des.setWidth("200px");
descLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
tableDisplay.setWidget(row, 2, des);

I'm placing the label inside a FlexTable

This is how it looks in the label. It's exceeding beyond the width I have given for the label.
Appears odd. I mean to say that the long text without whitespace is not following the width I have given for the label. Tried giving this:

public class Jlabel extends Label{
public  Jlabel () {
 DOM.setStyleAttribute(this.getElement(), "word-wrap", "break-word");
}

wwwwwwwwwr ttttttttttt rrrrrrrrrrrrrrrrr yyyyyyyyyyyyyyyyr rriuoeggn ryyyyyy ryj klrtp;irptiml;rtkroitlrktrpotilr;gkawpeti;lrkgwptjkrotkw;'rtoi4p[tok

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白龙吟 2024-09-21 15:23:22

浏览器只能对空白字符进行断词。所以你需要在长篇大论中提供一些内容。

一种选择是每 10 个字符插入 ­。如果该单词适合一行,则这将(不应该)不会显示。

Browsers can only break words on whitespace characters. So you need to provide some in your long word.

One option is to insert ­ every 10 characters. This will (should) not display if the word fits into a line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文