How to add a newline to JLabel without using HTML


I don't think there is direct(and easy) way of doing JLabel with multiple lines without recurring to HTML. You can use JTextArea instead.

JTextArea textArea = new JTextArea();
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setOpaque(false);
textArea.setBorder(BorderFactory.createEmptyBorder());
add(textArea, BorderLayout.CENTER);

It should look almost the same. If you have different fonts for different components, you can add the following line to ensure that the font of JTextArea is the same with JLabel

textArea.setFont(UIManager.getFont("Label.font"));

Hope this helps.


SwingX supports multiline labels:

   JXLabel label = new JXLabel();
   label.setLineWrap(true);