我希望在我身上有这样的方法 DocumentFilter
public void replaceUpdate(int offset, int length, String text) {
try {
super.replace(byPass, offset, length, text, null);
} catch (BadLocationException ex) {
//error
}
}
Run Code Online (Sandbox Code Playgroud)
目前为了获得FilterBypass的实例(上面的方法中的byPass),我需要从重写的方法insertString获取:
private FilterBypass byPass;
@Override
public void insertString(DocumentFilter.FilterBypass fb,
int offset, String string, AttributeSet att)
throws BadLocationException {
byPass = fb;
//some stuff here
super.insertString(fb, offset, string, att);
}
Run Code Online (Sandbox Code Playgroud)
但这给我带来了一些问题.任何人都可以建议一些不同的方式获得FilterBypass?我无法找到一种方法来获得FilterBypass不同的参考.
如果我要覆盖它的方法应该怎么做?