First of all, it would look like you are using a KeyListener
to try and filter a text field, this is a bad idea and can lead to many issues and inconsistencies. Instead you should be using a DocumentFilter
, which is designed to do just this.
You could store a reference to the original border before your start...
Border border = flatNoField_addUser.getBorder();
And simply reapply it when you need to.
A more generic solution would be to ask the UIManger...
Border border = UIManager.getBorder("TextField.border");
The problem with this is it does not take into consideration the use case where the field had a non-default border