I use a JEditorPane to render some HTML in a swing application. I use a bullet point list <ul><li>...</li></ul>
and I obtain overly large bullet points in the output. The same HTML chunk will show normal sized bullet points in a real browser.
I observed this on Windows 7 / JDK 7 and iirc also on Ubuntu and OpenJDK 1.7.0_09.
Is this known? Is there a way around it?
Working example:
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
/**
*
*/
public class HTMLTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// create new frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setSize(500, 500);
// create editor pane and fill with some html
JEditorPane pane = new JEditorPane();
pane.setContentType("text/html");
pane.setEditable(false);
pane.setText("<html><h1>Heading</h1>Text<ul><li>Bullet point</li></ul></html>");
// add editor pane to frame and set frame visible
frame.add(pane);
frame.setVisible(true);
}
}
P.S.: I am now using
ul {
list-style-type: none;
margin-left: 10px
}
in a css file and
<li>• Item 1</li>
in the html to have a decent bullet point. Solution inspired by aterai.
text-indent: -20px; padding-left: 20px
to indent the text to theright of the bullet symbol. I haven't found out how to automatically align the indent with the bullet size though. – Knawel