3

I have made a java swing GUI. Now I want to display a static message on that but the message is multi-line and the JLabel is single line.

How can I display that message?

Is there any property of JLabel which we can set to display the multiple line message?

Will I have to use several JLabels for multiple lines?

Is there any other way I can display that message?

Amit
  • 33,847
  • 91
  • 226
  • 299

2 Answers2

8

How to Use HTML in Swing Components

Displaying Multi Line Text

camickr
  • 321,443
  • 19
  • 166
  • 288
7

You can do

JLabel l = new JLabel("<html><p>Hello World! blah blah blah</p></html>");

and it will automatically wrap it where appropriate.

nevster
  • 6,271
  • 7
  • 35
  • 42