title: Linked ComboBoxes
body: <p>I am trying to make linked <code>ComboBoxes</code>. For example, I have three comboboxes and each of them have three items (a, b, c). In the beggining at the first combobox "a" is selected, in the second "b", and "c" in the third. I need to make such <code>ActionListener</code> for them, that works in this way: if change selection in the second list from "b" to "a", in the first list selected item automatically changes from "a" to "b".</p>
  
  <p>I tried to solve the problem in that way:</p>
  
  <pre><code> public class MyComboBoxListener implements ActionListener {
  
          public void actionPerformed(ActionEvent a) {
              int i = 0;
              int j = 0;
              while (a.getSource() != valsListArray.get(i)) {
                  i++;
              }
              String selected = valsListArray.get(i).getSelectedItem().toString();
              while (selected != valsListArray.get(j).getSelectedItem() &amp;&amp; j != i) {
                  j++;
              }
              String r = chosenVals[i];// in the beginnig elements are that order a, b, c
              valsListArray.get(j).setSelectedItem(chosenVals[i]);
              chosenVals[j] = r;
              chosenVals[i] = selected;
          }
      }
  </code></pre>
  
  <p>but it does not solve the problem.</p>