I've been for a while searching through here and other Java forums. Also googling it, but I haven't found anything that matches my expectations (a line break, basically). I've achieved this:
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);
}
That allows me to send messages to a chat room I'm creating, how can I make the line break to go to the next line?
Thank you all! (Similar but not equal posts: First post and The second one)