private Component addDoubleControl(final Dictionary<String, Object> dictionary,
final String key, Form.Section section) {
double value = (Double)dictionary.get(key);
TextInput textInput = new TextInput();
textInput.setTextSize(14);
textInput.setValidator(new DoubleValidator());
textInput.setText(String.valueOf(value));
section.add(textInput);
Form.setLabel(textInput, key);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
try {
dictionary.put(key, Double.parseDouble(textInput.getText()));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
double value = (Double)dictionary.get(key);
textInput.setText(String.valueOf(value));
}
}
}
});