Code: Select all
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
public class HTMLabelTryout {
private static final String TEXT =
"This is a paragraph."
+ "This is another paragraph.";
private static final String TEXT2 =
"
This is a paragraph.
"
+ "
This is another paragraph.
";
public static void main(String[] args) {
SwingUtilities.invokeLater(new HTMLabelTryout()::showFrame);
}
private void showFrame() {
JFrame frm = new JFrame();
frm.add(new JLabel(TEXT), BorderLayout.PAGE_START);
frm.add(new JLabel(TEXT2), BorderLayout.PAGE_END);
frm.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frm.setSize(900, 400);
frm.setLocationRelativeTo(null);
frm.setVisible(true);
}
}