I'm wanting to create a large text field for a user to type something in. I also want it to use the default system font to match the look and feel that is expected. So I tried to use a JEditorPane with the default constructor, which uses plain text encoding.
JEditorPane editorPane = new JEditorPane();
editorPane.setText(gettysburgAddress);
The trouble with this is that plain text encoding doesn't wrap to a newline at the end of each word, only when it runs out of characters.
I tried using the HTML encoding, which word wraps:
JEditorPane editorPane = new JEditorPane("text/html", "");
editorPane.setText(gettysburgAddress);
This has the word wrap, but it defaults to a different font than the default for the system (Helvetica on Mac OS X, which I don't want.
How can I get the best of both worlds: word wrap and the system default font? I don't need any special formatting or anything for this, so plain text encoding will do if it is possible.
SimpleAttributeSet
, for example. – MaxinemaxiskirtTurn it into an answer showing it
- What? I'm not going to write the code for you. If you tried it on your own you should have your answer by now. – Metathesize