JComponent addValidatedTextField(JPanel parent, TextFieldEditor textEditor, String labelText, String propertyName, String validatorRegex) { if(validatorRegex == null || validatorRegex.isEmpty()){ return addTextField(parent, textEditor, labelText, propertyName, false, null); } else { JLabel jLabel = new JLabel(labelText); parent.add(jLabel); PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName); propertyDescriptor.setValidator(new PatternValidator(Pattern.compile(validatorRegex))); JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, bindingContext); UIUtils.addPromptSupport(editorComponent, "enter " + labelText.toLowerCase().replace(":", "") + " here"); editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight)); editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight)); jLabel.setLabelFor(editorComponent); parent.add(editorComponent); return editorComponent; } }