views:

178

answers:

1

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.

+1  A: 

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.

Jason Hall