cdc.bench.support.ui.swing.CheckedTextField Maven / Gradle / Ivy
package cdc.bench.support.ui.swing;
import javax.swing.JTextField;
import cdc.bench.support.checks.CheckResult;
import cdc.bench.support.checks.Checker;
import cdc.bench.support.ui.swing.InputChecker.FocusPolicy;
public class CheckedTextField extends JTextField {
private static final long serialVersionUID = 1L;
private Checker checker;
public CheckedTextField() {
super();
}
public CheckedTextField(Checker checker) {
this();
setChecker(checker);
}
public void setChecker(Checker checker) {
this.checker = checker;
setInputVerifier(new TextInputChecker(this, FocusPolicy.NORMAL_TRANSFER, checker));
}
public CheckResult.Status getStatus() {
if (checker == null) {
return CheckResult.Status.OK;
} else {
return checker.check(getText()).getStatus();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy