Если вы можете контролировать вводимый текст и используете функции JEditorPane, вы можете пометить код с помощью html и использовать пробел: nowrap; свойство стиля.
jEditorPane1.setContentType("text/html");
StringBuilder sb = new StringBuilder();
sb.append("<div style='");
if (!wordWrap.isSelected()) { //some checkbox
sb.append("white-space:nowrap;");
}
sb.append("font-family:\"Monospaced\">'");
sb.append("your very interesting long and full of spaces text");
/*be aware, more then one space in row will be replaced by single space
to avoid it you need to substitute by .
Also rememberer that \n have to be repalced by <br>
so filering like:
line = line.replaceAll("\n", "<br>\n"); //be aware, <br/> do not work
line = line.replaceAll(" ", " ");
line = line.replaceAll("\t", " ");
may be usefull.*/
sb.append("</div>");
jEditorPane1.settext(sb.toString()); //jeditor pane do not support addition/insertion of text in html mode