import java.awt.*;
import javax.swing.*;
public class MultilineLabel {
public static void main(String[] args) {
String str = "This is \nmy example \nof a multi-line \nJLabel";
JLabel strLabel = new JLabel (str);
display(strLabel, "Hmmm...");
}
public static void display(JComponent comp, String title) {
JFrame f = new JFrame(title);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(comp);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}