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
  • 166,747
  • 40
  • 210
  • 420
bardockyo
  • 1,385
  • 6
  • 20
  • 32

1 Answers1

3

For list data, use a JList instead.

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

Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420