Skip to content

Instantly share code, notes, and snippets.

@mansour-gabteni
Last active June 4, 2017 15:45
Show Gist options
  • Select an option

  • Save mansour-gabteni/02c2feda4cca2810043de92eadb6bdcc to your computer and use it in GitHub Desktop.

Select an option

Save mansour-gabteni/02c2feda4cca2810043de92eadb6bdcc to your computer and use it in GitHub Desktop.
class ComboItem
{
private String key;
private String value;
public ComboItem(String key, String value)
{
this.key = key;
this.value = value;
}
@Override
public String toString()
{
return key;
}
public String getKey()
{
return key;
}
public String getValue()
{
return value;
}
}
comboBox.addItem(new ComboItem("Visible String 1", "Value 1"));
comboBox.addItem(new ComboItem("Visible String 2", "Value 2"));
comboBox.addItem(new ComboItem("Visible String 3", "Value 3"));
Object item = comboBox.getSelectedItem();
String value = ((ComboItem)item).getKey();
String value = ((ComboItem)item).getValue();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment