import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.Element;
import javax.swing.text.StyleConstants;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;
public class Main extends javax.swing.JFrame {
public Main() {
JEditorPane editorPane = new JEditorPane();
JScrollPane scrollPane = new JScrollPane();
this.setPreferredSize(new Dimension(300, 300));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
editorPane.setEditorKit(new PreWrapHTMLEditorKit());
editorPane
.setText(""
+ "<html>"
+ "<head></head>"
+ "<body>"
+ "<pre>long text line long text line long text line long text line (two new lines here!)\n\n"
+ "long text line long text line long text line long text line long text line long text line</pre>"
+ "</body>" + "</html>");
scrollPane.setViewportView(editorPane);
getContentPane().add(scrollPane);