0

Is it possible to create multiline label in WindowBuilder?

Methods below failed:

1) JLabel with \n-s

2) JLabel with text, wrapper into <html> and maximuSize set

3) JTextPane with and withot <html>

Why???

Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
  • I don't use WindowBuilder, but when I need multiline labels in Java, I use with
    .
    – KathyA. Jun 23 '14 at 16:24
  • You asked about a label, so I assumed you meant a JLabel. See http://stackoverflow.com/questions/685521/multiline-text-in-jlabel – KathyA. Jun 23 '14 at 18:11

1 Answers1

2

If you want to display multiline text in a JLabel, use html tags like this:

JLabel label = new JLabel("<html>First line and maybe second line</html>");

If you want to be able to control the line-break, use standard html
tags:

JLabel label = new JLabel("<html>First line<br>Second line</html>");
Vortex
  • 173
  • 3
  • 12