private static Component addColorControl(final Dictionary<String, Object> dictionary,
final String key, Form.Section section) {
Color color = (Color)dictionary.get(key);
ColorChooserButton colorChooserButton = new ColorChooserButton();
colorChooserButton.setSelectedColor(color);
section.add(colorChooserButton);
Form.setLabel(colorChooserButton, key);
colorChooserButton.getColorChooserButtonSelectionListeners().add
(new ColorChooserButtonSelectionListener() {
@Override
public void selectedColorChanged(ColorChooserButton colorChooserButton,
Color previousSelectedColor) {
try {
dictionary.put(key, colorChooserButton.getSelectedColor());
} catch (Exception exception) {
displayErrorMessage(exception, colorChooserButton.getWindow());
dictionary.put(key, previousSelectedColor);
}
}
});