Hi,
I have encountered a problem when validation error is detected in a form, where the form control is contained in a JScrollPane in an AbstractView.
I noticed that when I put the form control in a JScrollPane, the cursor on textfields that are invalid loses focus and the cursor automatically jumps to the next widget (JTextField/JRadioButton/...). When I place the cursor back on the textfield with the error and cause subsequent validation errors on it, it is fine; the cursor doesn't jump. The problem lies with the initial detection of the validation error on the first textfield. Now, if I did not put the form component in a JScrollPane, all is fine; the cursor doesn't jump to the next widget automatically.
I tried this out on the pet clinic sample, and it is also the case.
To replicate this, in the class OwnerGeneralForm.java, add the form control into a JScrollPane in the method createFormControl(), like so:
Now, in the first name field, just backspace till no values are in the field. This will cause a validation error. Notice that the cursor automatically jumps to the next field.Code:protected JComponent createFormControl() { TableFormBuilder formBuilder = new TableFormBuilder(getFormModel()); this.firstNameField = formBuilder.add("firstName")[1]; formBuilder.row(); formBuilder.add("lastName"); return new JScrollPane(formBuilder.getForm()); }
Does anyone know why this is occuring and a possible fix for it? I can't seem to locate the root cause.
Thanks in advance.


Reply With Quote