chris
unread,Nov 6, 2009, 8:23:50 AM11/6/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
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("<b>" + user + ":</b>
"+message));
flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows+1);
this.scrollToBottom();
}
}