I have this code to display HTML
formatted string:
JTextPane pane = new JTextPane();
pane.setContentType("text/html");
pane.setEditable(false);
pane.setText(
"<html>" +
"<body style='font-size:18px'>" +
"<h1>Error:</h1>" +
"<p>" +
"Could not read the file <code>none.txt</code>. " +
"Perhaps it does not exist in the specified location, " +
"or possibly there is no access to it" +
"</p>" +
"</body>" +
"</html>");
add(pane);
But this is the output:
You can see that the none.txt
string doesn't inherit the font size of its enclosing paragraph, although this is what's supposed to happen in HTML (see jsfiddle).
How do I fix this?
tags, then restate the body tag afterwards? Example: "Could not read the file
none.txt
– joey942 Dec 14 '16 at 13:46none.txt
` from `` should work, and how can we have more than one ``? anyway, tried that, it completely ignores the whole content of ``, and all I see is the "Error:" text.
– Tar Dec 14 '16 at 13:56none.txt