For something JLabel
, you would need to first replace the new lines (\n
) with <br>
and wrap the text in <html>...</html>
String Sentence = new String(receivePacket.getData());
//Print received text to GUI:
label.setText("<html>" + Sentence.replaceAll("\n", "<br>") + "</html>");
Or you might be able to use a non-editable JTextArea
instead...