}
}
private Component addLimitsControl(final Dictionary<String, Object> dictionary,
final String key, Form.Section section) {
Limits limits = (Limits)dictionary.get(key);
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
section.add(boxPane);
Form.setLabel(boxPane, key);
FlowPane flowPane = new FlowPane();
flowPane.getStyles().put("alignToBaseline", true);
flowPane.getStyles().put("horizontalSpacing", 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(limits.min));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Limits limits = (Limits)dictionary.get(key);
try {
int min = Integer.parseInt(textInput.getText());
dictionary.put(key, new Limits(min, limits.max));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(limits.min));
}
}
}
});
Label label = new Label("min");
label.getStyles().put("font", "{italic:true}");
flowPane.add(label);
flowPane = new FlowPane();
flowPane.getStyles().put("alignToBaseline", true);
flowPane.getStyles().put("horizontalSpacing", 5);
boxPane.add(flowPane);
textInput = new TextInput();
textInput.setTextSize(10);
textInput.setMaximumLength(10);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(limits.max));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Limits limits = (Limits)dictionary.get(key);
try {
int max = Integer.parseInt(textInput.getText());
dictionary.put(key, new Limits(limits.min, max));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(limits.max));
}
}