@Override
		public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {

			// form a string that is the current document text with the indicated part deleted
			StringBuilder builder = getText(fb);
			builder.delete(offset, offset + length);

			// if the new formed text is valid, allow the operation.
			if (isValid(builder)) {
				super.remove(fb, offset, length);
			}
		}
DocumentFilter that prevents users from entering invalid data into the field.
Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/IntegerTextField.java