sl.setSnapToTicks(true);
// POJO binding magic...
personPA.bindBidirectional(path, sl.valueProperty());
ctrl = sl;
} else if (controlType == PasswordField.class) {
final PasswordField tf = new PasswordField() {
@Override
public void replaceText(int start, int end, String text) {
if (matchTest(text)) {
super.replaceText(start, end, text);
}
}
@Override
public void replaceSelection(String text) {
if (matchTest(text)) {
super.replaceSelection(text);
}
}
private boolean matchTest(String text) {
return text.isEmpty()
|| (text.matches(restictTo) && (getText() == null || getText()
.length() < maxChars));
}
};
// POJO binding magic...
personPA.bindBidirectional(path, tf.textProperty());
ctrl = tf;
} else if (controlType == CalendarTextField.class) {
final CalendarTextField ctf = new CalendarTextField();
personPA.bindBidirectional(path, ctf.calendarProperty(),
Calendar.class);
ctrl = ctf;
} else if (controlType == ListSpinner.class) {
final ListSpinner<T> ls = new ListSpinner<>(choices)
.withCyclic(true);
personPA.bindBidirectional(path, ls.valueProperty(),
(Class<T>) choices[0].getClass());
ctrl = ls;
} else {
final TextField tf = controlType == PasswordField.class ? new PasswordField() {
@Override
public void replaceText(int start, int end, String text) {
if (matchTest(text)) {
super.replaceText(start, end, text);
}
}
@Override
public void replaceSelection(String text) {
if (matchTest(text)) {
super.replaceSelection(text);
}
}
private boolean matchTest(String text) {
return text.isEmpty()
|| (text.matches(restictTo) && (getText() == null || getText()
.length() < maxChars));
}
}
: new TextField() {
@Override
public void replaceText(int start, int end, String text) {
if (matchTest(text)) {
super.replaceText(start, end, text);
}
}
@Override
public void replaceSelection(String text) {
if (matchTest(text)) {
super.replaceSelection(text);
}
}
private boolean matchTest(String text) {
return text.isEmpty()
|| (text.matches(restictTo) && (getText() == null || getText()
.length() < maxChars));
}
};
// POJO binding magic...
personPA.bindBidirectional(path, tf.textProperty());
ctrl = tf;
}
box.getChildren()
.addAll(new Label(
path