void (Map<String, String> map) { for (Map.Entry<String, JComponent> entry : myKey2Component.entrySet()) { final JComponent component = entry.getValue(); String value = null; if (component instanceof JTextComponent) { value = ((JTextComponent)component).getText(); } else if (component instanceof TextFieldWithBrowseButton) { value = ((TextFieldWithBrowseButton)component).getTextField().getText(); } else if (component instanceof JCheckBox) { value = ((JCheckBox) component).isSelected() ? "yes" : "no"; } if ((value != null) && (!value.isEmpty() || map.containsKey(entry.getKey()))) { map.put(entry.getKey(), value); } } }