}
}
private static Component addPointControl(final Dictionary<String, Object> dictionary,
final String key, Form.Section section) {
Point point = (Point)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(3);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(point.x));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Point point = (Point)dictionary.get(key);
try {
int x = Integer.parseInt(textInput.getText());
dictionary.put(key, new Point(x, point.y));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(point.x));
}
}
}
});
Label label = new Label("x");
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(3);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(point.y));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Point point = (Point)dictionary.get(key);
try {
int y = Integer.parseInt(textInput.getText());
dictionary.put(key, new Point(point.x, y));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(point.y));
}
}