How to add a newline to JLabel without using HTML

Nauphal picture Nauphal · Sep 7, 2011 · Viewed 26.1k times · Source

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.

Answer

kleopatra picture kleopatra · Sep 7, 2011

SwingX supports multiline labels:

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