void () { myNameBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() != ItemEvent.SELECTED) return; String key = (String)e.getItem(); String value = myAvailableProperties.get(key); if (value != null) myValueField.setText(value); } }); }