このような方法を自分に持たせたいDocumentFilter
public void replaceUpdate(int offset, int length, String text) {
try {
super.replace(byPass, offset, length, text, null);
} catch (BadLocationException ex) {
//error
}
}
現在、 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);
}
しかし、これは私にいくつかの問題を引き起こしています。FilterBypass を取得する別の方法を提案できる人はいますか? 別のものへの参照を取得する方法が見つかりませんFilterBypass
。
そのメソッドをオーバーライドする場合、どうすればよいですか?