FlowPane flowPane = new FlowPane();
flowPane.getStyles().put("alignToBaseline", true);
flowPane.getStyles().put("horizontalSpacing", 5);
boxPane.add(flowPane);
TextInput textInput = new TextInput();
textInput.setTextSize(4);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(insets.top));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Insets insets = (Insets)dictionary.get(key);
try {
int top = Integer.parseInt(textInput.getText());
dictionary.put(key, new Insets(top, insets.left, insets.bottom,
insets.right));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(insets.top));
}
}
}
});
Label label = new Label("top");
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(4);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(insets.left));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Insets insets = (Insets)dictionary.get(key);
try {
int left = Integer.parseInt(textInput.getText());
dictionary.put(key, new Insets(insets.top, left, insets.bottom,
insets.right));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(insets.left));
}
}
}
});
label = new Label("left");
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(4);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(insets.bottom));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Insets insets = (Insets)dictionary.get(key);
try {
int bottom = Integer.parseInt(textInput.getText());
dictionary.put(key, new Insets(insets.top, insets.left, bottom,
insets.right));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(insets.bottom));
}
}
}
});
label = new Label("bottom");
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(4);
textInput.setMaximumLength(4);
textInput.setValidator(new IntValidator());
textInput.setText(String.valueOf(insets.right));
flowPane.add(textInput);
textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
@Override
public void focusedChanged(Component component, Component obverseComponent) {
if (!component.isFocused()) {
TextInput textInput = (TextInput)component;
Insets insets = (Insets)dictionary.get(key);
try {
int right = Integer.parseInt(textInput.getText());
dictionary.put(key, new Insets(insets.top, insets.left, insets.bottom,
right));
} catch (Exception exception) {
displayErrorMessage(exception, component.getWindow());
textInput.setText(String.valueOf(insets.right));
}
}
}
});