First steps with GWT - 002

Multi-lines Label

GWT has the widget Label to display the text on one single line (ignoring the end-of-line characters).

Problem:
We want to display multi-lines text in a "fatter" label (big size, let's say 500x400 pixels).

Solution:
The classic end of lines in Java or HTML doesn't work "\n", "\r\n" or <br> . So, what can we do?

We can use the bellow magic lines of code:

Label textLabel = new Label ("bla bla \n bla bla", false);
DOM.setStyleAttribute(textLabel.getElement(), "whiteSpace", "pre");

Adding this label to a scroll panel will assure that the scroll functionality is available too, for too many lines of text :-)