Wie kann man die Tabulatorbreite (Tabstop) des JTextPanes verändern?
public void setTabWidth(int charactersPerTab) {
this.tabWidth = charactersPerTab;
FontMetrics fm = getFontMetrics(getFont());
int charWidth = fm.charWidth('w');
int tabWidth = charWidth * charactersPerTab;
TabStop[] tabs = new TabStop[50];
for(int j = 0; j < tabs.length; j++) {
int tab = j + 1;
tabs[j] = new TabStop(tab * tabWidth);
}
TabSet tabSet = new TabSet(tabs);
SimpleAttributeSet attributes = new SimpleAttributeSet();
StyleConstants.setTabSet(attributes, tabSet);
int length = getDocument().getLength();
getStyledDocument().setParagraphAttributes(0, length, attributes, false);
}