java - Word Wrap in JEditorPane and System Font -
i'm wanting create large text field user type in. want use default system font match , feel expected. tried use jeditorpane default constructor, uses plain text encoding.
jeditorpane editorpane = new jeditorpane(); editorpane.settext(gettysburgaddress);
the trouble plain text encoding doesn't wrap newline @ end of each word, when runs out of characters.
i tried using html encoding, word wraps:
jeditorpane editorpane = new jeditorpane("text/html", ""); editorpane.settext(gettysburgaddress);
this has word wrap, defaults different font default system (helvetica on mac os x, don't want.
how can best of both worlds: word wrap , system default font? don't need special formatting or this, plain text encoding if possible.
if needed word-wrapped jeditorpane using system font, , don't need special stylized text or images, it's best switch jtextarea, text component doing plain text. doesn't word wrap default, it's easy make happen:
jtextarea textarea = new jtextarea(); textarea.setlinewrap(true); //makes text wrap next line textarea.setwrapstyleword(true); //makes text wrap full words, not letters textarea.settext(gettysburgaddress);
if absolutely must use jeditorpane reason, you'll have roll sleeves , make changes way jeditorpane rendering text. on plus side, have several different methods choose from. can:
Comments
Post a Comment