tags:

views:

41

answers:

1
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

+1  A: 

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.

Aaron Digulla
i have provided a text area for the user to add some description and iam capturing tat desc and placing it in a label .i dont want to display using textarea as i was asked to.Whts the fix for it
krithika
I don't understand what you want to "fix". What is your goal?
Aaron Digulla
i want to knw how can i break a long text incase if the user enters something of this sortwwwwwwwwwr ttttttttttt rrrrrrrrrrrrrrrrr yyyyyyyyyyyyyyyyr rriuoeggn ryyyyyy ryj klrtp;irptiml;rtkroitlrktrpotilr;gkawpeti;lrkgwptjkrotkw;'rtoi4p[tok
krithika
As I said in my answer: Search for long words and insert "­" every 10 characters.
Aaron Digulla
Here's a good [article](http://www.cs.tut.fi/~jkorpela/shy.html) about the soft hyphen "­"
Chris Lercher
A similar solution would be using some sort of JS library for this, like: http://code.google.com/p/hyphenator/
Igor Klimer