I am trying to change the Font size of a JEditorPane by using following method
Code :setFont(new Font("Verdana", Font.PLAIN, 10));
but it the font doesn't change. Is there anything else that I should set up?
Printable View
I am trying to change the Font size of a JEditorPane by using following method
Code :setFont(new Font("Verdana", Font.PLAIN, 10));
but it the font doesn't change. Is there anything else that I should set up?
More info is needed. Based upon your other posts if you are setting the content type of the JEditorPane to html, I don't think the change in font makes a different and any changes should be specified in the html itself.
yes the content is html. the problem is that when the file is displayed by web browser the font size is normal but when it is shown in the JEditorPane the words become larger. I want to force JEditorPane to keep the original fone size.
You could try altering the default font the JEditorPane uses by setting the font via css
Code :((HTMLDocument)editorPane.getDocument()).getStyleSheet().addRule(""+ "body{"+ "font-family:Arial;"+//whatever font you want "font-size:12px;"+//font size ""})
what you have sent has some errors I test the following code but it doesn't do any thing.
Code :HTMLEditorKit Hkit = new HTMLEditorKit(); editorpane.setEditorKit(Hkit); StyleSheet HstyleSheet = Hkit.getStyleSheet(); HstyleSheet.addRule(""+ "body{"+ "font-family:Arial;"+//whatever font you want "font-size:4px;"+//font size "");
Hopefully this link will help you:
http://www.javaprogrammingforums.com...ize-color.html