import javax.swing.JTextField;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.hibernate.validator.constraints.NotBlank;
public class Test {
public static void main(String[] args) {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
// Throws exception
validator.validateValue(TestPanel.class, "testField", "testString", new Class[0]);
}
}
class TestPanel {
@NotBlank
public JTextField testField = new JTextField();
}