1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
protected class Filtre extends DocumentFilter implements Serializable {
public Filtre() {
}
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String str, AttributeSet attr) throws BadLocationException {
replace(fb, offset, 0, str, attr);
}
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String str, AttributeSet attrs) throws BadLocationException {
fb.remove(offset, length);
int offsetMemory = offset;
String[] T = s.split(" ",-1);
fb.insertString(offset, T[0], attrs);
for(int i=1; i<T.length; i++) {
offsetMemory += T[i - 1].length();
try {
editorKit.insertHTML(sdoc, offsetMemory, " ", 0, 0, null);
} catch (IOException ex) {
Logger.getLogger(JMathTextPane.class.getName()).log(Level.SEVERE, null, ex);
}
fb.insertString(offsetMemory, T[i], attrs);
}
}
} |
Partager