我有一个文本字段,用于表格的过滤器行。
当失去字段焦点时,在文本字段中显示按....项过滤。
当获得焦点时,隐藏此字符串
我如何忽略撤消和重做中的按...项过滤
private static final UndoManager MANAGER = new UndoManager();
private boolean isLabel() {
return filterField.getText().startsWith("Search by") && filterField.getText().endsWith("items");
}
public void actionPerformed(ActionEvent event) {
if (event.getSource().equals(undoField)) {
try {
MANAGER.undo();
if (isLabel()) {
throw new CannotUndoException();
}
} catch (CannotUndoException e) {
System.out.println("cannot undo");
}
}
else if (event.getSource().equals(redoField)) {
try {
MANAGER.redo();
if (isLabel())
throw new CannotRedoException();
} catch (CannotRedoException e) {
System.out.println("cannot redo");
}
}