如何在 GWT 标签中换行很长的文本行?

发布于 2024-08-30 08:42:24 字数 528 浏览 2 评论 0原文

这是我目前代码的摘录:

VerticalPanel mainPanel = new VerticalPanel();
RootPanel.get("messages").add(mainPanel);

HorizontalPanel tempPanel = new HorizontalPanel();
tempPanel.setSize("100px", "200px");

Label content = new Label("AAAveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongtextZZZ");
content.setWidth("50px");
content.setWordWrap(true);

tempPanel.add(content);
mainPanel.add(tempPanel);

标签显示但不换行。 如果我插入一个空格,似乎可以自动换行,但我想我想要字符换行。 有什么想法吗?

我不想要水平滚动条。

This is an extract of my code at the moment:

VerticalPanel mainPanel = new VerticalPanel();
RootPanel.get("messages").add(mainPanel);

HorizontalPanel tempPanel = new HorizontalPanel();
tempPanel.setSize("100px", "200px");

Label content = new Label("AAAveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongtextZZZ");
content.setWidth("50px");
content.setWordWrap(true);

tempPanel.add(content);
mainPanel.add(tempPanel);

The label displays but it does not wrap.
If I insert a space it seems that word wrap works, but I guess I want character wrap.
Any ideas?

I do not want a horizontal scrollbar.

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

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

发布评论

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

评论(2

又爬满兰若 2024-09-06 08:42:24

这实际上更像是一个 CSS 问题,而不是一个 GWT 问题。 setWordWrap() 通常用于取消在 div 上设置自动换行 - 默认情况下自动换行(在空白处)。

你想要做的就是在标签中添加一些CSS,上面写着 { word-wrap: break-word; }

更多信息此处

This is really more of a CSS question, than a GWT question. setWordWrap() is typically used to un-set word wrap on a div -- word wrapping (on whitespace) is the default.

What you want to do is add some CSS to the Label that says { word-wrap: break-word; }

More information here.

岁月无声 2024-09-06 08:42:24

我使用了 label.setStyleAttribute("whiteSpace", "normal");

I used label.setStyleAttribute("whiteSpace", "normal");

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