//using a combobox to do basic sums int iNum1 = 420; int iNum2 = 69;  if (combobox.getSelectedItem().equals("Add"))    int iAns = iNum1 + iNum2; else if (combobox.getSelectedItem().equals("Subtract"))    int iAns = iNum1 - iNum2;

Read more of this post