public OurSyntaxWidget
(boolean enableSyntax, String text, String fontName, int fontSize, int tabSize, JComponent obj1, JComponent obj2) {
this.obj1 = obj1;
this.obj2 = obj2;
final OurSyntaxWidget me = this;
final ViewFactory defaultFactory = (new StyledEditorKit()).getViewFactory();
doc.do_enableSyntax(enableSyntax);
doc.do_setFont(fontName, fontSize, tabSize);
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) {} }
};
}