-2
我已经搜索了一下这里和其他Java论坛。也搜索它,但我没有发现任何符合我的期望(基本上是一个换行符)。我已经实现了这一点:在不使用HTML的情况下在JTextPane中进行换行
public final void messageRoom (String message, Boolean bold, Color color) {
StyledDocument document = new DefaultStyledDocument();
SimpleAttributeSet attributes = new SimpleAttributeSet();
if(bold) {
attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
}
attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, color);
try {
document.insertString(document.getLength(), message, attributes);
} catch (BadLocationException ex) {
System.out.println("ex");
}
chatArea.setStyledDocument(document);
}
这使我可以发送消息到我创建的聊天室,我该如何让换行符到下一行?
谢谢大家! (类似但不等于帖子:First post和The second one)
这不是StackOverflow的工作原理。作为一个问题,你不要只发布你很酷的东西。在你的问题中,清楚简洁地描述问题,并附上代码示例等。如果您也有答案,请将其作为答案,与问题分开,然后在需要的延迟后,接受您的答案。我们不会在标题中加入“已解决”,也不要在问题中提供答案。请访问[帮助]并阅读[问]和[答案]。 –