Example usage for javax.swing JComponent setInputVerifier

List of usage examples for javax.swing JComponent setInputVerifier

Introduction

In this page you can find the example usage for javax.swing JComponent setInputVerifier.

Prototype

@BeanProperty(description = "The component's input verifier.")
public void setInputVerifier(InputVerifier inputVerifier) 

Source Link

Document

Sets the input verifier for this component.

Usage

From source file:org.esa.snap.ui.tooladapter.dialogs.ToolParameterEditorDialog.java

private JComponent addTextPropertyEditor(JPanel parent, String label, String propertyName, String value,
        int line, boolean isRequired) {
    parent.add(new JLabel(label), getConstraints(line, 0, 1));
    PropertyDescriptor propertyDescriptor = container.getDescriptor(propertyName);
    TextFieldEditor textEditor = new TextFieldEditor();
    JComponent editorComponent = textEditor.createEditorComponent(propertyDescriptor, valuesContext);
    ((JTextField) editorComponent).setText(value);
    if (isRequired) {
        editorComponent.setInputVerifier(new RequiredFieldValidator("This field is required"));
    }/* w  ww  .j a va 2 s .c  o m*/
    parent.add(editorComponent, getConstraints(line, 1, 1));
    return editorComponent;
}