I'm writing a program using Swing that involves a form. When the form is submitted, I have a function that validates it, and any invalid fields are supposed to be highlighted in red to be corrected, then changed back to the default border once valid.
Currently, I am using the following method to get the default JTextField
border.
private Border defaultBorder = new JTextField().getBorder();
Is there a way to do this without creating an unnecessary object?
More importantly, how do I change the color of the border without affecting its other properties?