JTextPane component is an advanced component for working with text.
import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; public class TextPane { public static void main(String[] args) throws Exception { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane textpane = new JTextPane(); textpane.setContentType("text/html"); textpane.setEditable(false); String cd = System.getProperty("user.dir") + "/"; textpane.setPage("File:///" + cd + "test.html"); textpane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); f.add(new JScrollPane(textpane)); f.setSize(new Dimension(380, 320)); f.setLocationRelativeTo(null); f.setVisible(true); } }