Possible duplicate:
Multi-line text in JLabel
I want to do this:
JLabel myLabel = new JLabel(); myLabel.setText("This is\na multi-line string");
This currently results in a label that displays
This isa multi-line string
I want him to do this instead:
This is a multi-line string
Any suggestions?
thank
EDIT: Implemented Solution
In the body of the method:
myLabel.setText(convertToMultiline("This is\na multi-line string"));
Helper Method:
public static String convertToMultiline(String orig) { return "<html>" + orig.replaceAll("\n", "<br>"); }
java string multiline swing jlabel
bguiz Jan 28 '10 at 6:33 2010-01-28 06:33
source share