How to wrap a very long line of text on a GWT label?

This is an excerpt from 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 is displayed, but it does not end. If I insert a space, the word wrap seems to work, but I guess I need a character wrapper. Any ideas?

I do not want a horizontal scrollbar.

+3
source share
2 answers

This is more a CSS question than a GWT question. setWordWrap()usually used to unbind words when wrapping div-word (by spaces) by default.

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

More details here .

+5
source

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

+2

Source: https://habr.com/ru/post/1742292/


All Articles