4

I have a method which returns a string that is formatted like so:

myString += "1. Hello\n" +
            "2. Goodbye\n";

I am attempting to display it as a JLabel but it is coming out

1. Hello 2. Goodbye

Is there a way to display the string with the newlines besides formatting it with HTML or is there another outlet to display the information correctly besides JLabel?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
bardockyo
  • 1,415
  • 6
  • 21
  • 32

1 Answers1

3

For list data, use a JList instead.

If this really is textual data, use a (noneditable) JTextArea.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433