GWT:如何防止在InlineLabel中删除前导/尾随空格?

时间:2017-08-08 14:16:16

标签: java html gwt

我有一行包含多个span元素的文本。例如:

<div class="line">
    <span class="username">mario_sunny: </span><span class="message">Hello would you like to buy a <span class="item">Match</span>?</span>
</div>

问题是当我尝试使用GWT的InlineLabelInlineHTML在Java中创建它时,它会修剪范围内的前导/尾随空格,如下所示:

enter image description here

如何防止这种情况?

这是我的代码:

HorizontalPanel lineLabel = new HorizontalPanel();
InlineHTML usernameLabel = new InlineHTML();
InlineLabel messageLabel = new InlineLabel();

lineLabel.setStyleName("chat-line");

usernameLabel.setStyleName("chat-username");
usernameLabel.setText("mario_sunny: ");

messageLabel.setText("Hello would you like to buy a Match?");

lineLabel.add(usernameLabel);
lineLabel.add(messageLabel);

0 个答案:

没有答案