pane.setEditorKit(new StyledEditorKit() { // Prevents line-wrapping up to width=30000, and tells it to use our Document obj
@Override public Document createDefaultDocument() { return doc; }
@Override public ViewFactory getViewFactory() {
return new ViewFactory() {
public View create(Element x) {
if (!AbstractDocument.SectionElementName.equals(x.getName())) return defaultFactory.create(x);
return new BoxView(x, View.Y_AXIS) { // 30000 is a good width to use here; value > 32767 appears to cause errors
@Override public final float getMinimumSpan(int axis) { return super.getPreferredSpan(axis); }
@Override public final void layout(int w, int h) { try {super.layout(30000, h);} catch(Throwable ex) {} }
};
}