On Mon, Nov 9, 2009 at 4:24 PM, chris wrote:
>
> If anyone has any ideas on this, it would be greatly appreciated.
>
> On Nov 6, 8:23 am, chris wrote:
>> I was wondering if anyone knew how to wrap text like several chat
>> applications do. I have a ChatArea private class that I am trying to
>> add to a widget. It works, however if a message to add to the chat
>> text is 1000 characters with no new lines, the ScrollPanel does not
>> wrap the text and adds a very long horizontal scroll.
>>
>> private class ChatPart extends ScrollPanel {
>>
>> final FlexTable flexTable = new FlexTable();
>>
>> ChatPart() {
>> super();
>> FlexCellFormatter cellFormatter =
>> flexTable.getFlexCellFormatter();
>> cellFormatter.setColSpan(0,0,2);
>> flexTable.addStyleName("chat-FlexTable");
>> flexTable.setWidth("100%");
>> this.add(flexTable);
>> this.setWidth("100%");
>> this.setHeight("300");
>> }
>>
>> /**
>> * Add a message
>> */
>> void addMessage(String user, String message) {
>> int numRows = flexTable.getRowCount();
>>
>> flexTable.getFlexCellFormatter().setVerticalAlignment(numRows, 0,
>> HasVerticalAlignment.ALIGN_TOP);
>>
>> flexTable.getFlexCellFormatter().setVerticalAlignment(numRows, 1,
>> HasVerticalAlignment.ALIGN_TOP);
>>
>> flexTable.getFlexCellFormatter().setWordWrap(numRows, 1, true);
>>
>> flexTable.setWidget(numRows, 0,
>> ChatApplication.images.greenIcon
>> ().createImage());
>> flexTable.setWidget(numRows, 1, new HTML("" +
>> user + ":
>> "+message));
HTML class has another constructor:
HTML(java.lang.String html, boolean wordWrap)
Try with:
flexTable.setWidget(numRows, 1, new HTML(""
+ user + ":
"+message, true));
>> flexTable.getFlexCellFormatter().setRowSpan(0, 1,
>> numRows+1);
>> this.scrollToBottom();
>> }
>> }
> >
>
--
Cheers,
Christian López Espínola
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---