editorPane.setContentType("text/html");
editorPane.setFont(new Font("Segoe UI", 0, 14));
editorPane.setText("Hello World");
This does not change the font of the text. I need to know how to set the default font for the JEditorPane with HTML Editor Kit.
Edit:
Try this one:
JEditorPane pane = new JEditorPane();
pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
pane.setFont(SOME_FONT);
All credits to de-co-de blogger! Source: http://de-co-de.blogspot.co.uk/2008/02/setting-font-in-jeditorpane.html
I have just tested it. This made JEditorPane to use same font as JLabel
JEditorPane pane = new JEditorPane();
pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
pane.setFont(someOrdinaryLabel.getFont());
Works perfectly.