Q:

How to add a newline to JLabel without using HTML

How can I add a new line to a JLabel? I know if I use simple HTML, it will work. But if I use HTML, JLabel is not showing the font which embedded with the application. I am embedding the font using the method - createFont() and using JLabel.setFont() for applying the font.

A:

SwingX supports multiline labels:
   JXLabel label = new JXLabel();
   label.setLineWrap(true);

A:

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.

A:

JLabel is not originally intended for multiline text, from what I recall.  You would need to override the various rendering methods to do the text line splitting manually.
Perhaps you should rather use a non-editable JTextArea if you want multiline labels.

