title: Clearing Last Selected Value JCombobox when ComboBoxModel Becomes Empty
body: <p><strong>Here is a scenario:</strong></p>
  
  <p><strong>I have two JComboBoxes</strong> (call them combo1 and combo2 ) that <strong>get their values from a database</strong>[In the DB, these two have a 1:M relationship]. When the screen shows up I populate combo1 with values from the database and then take the first entry in the list and get its corresponding values to populate combo2. </p>
  
  <p>Since the values of combo2 depend on what is selected in combo1, every time the selection changes in combo1 a call is made to the database to get matching values to populate combo2.</p>
  
  <p><strong>Now here is a problem:</strong></p>
  
  <p>Say I have two entries in combo1 and the second entry has no corresponding values for combo2. When I select the second entry of combo1, the last selected value on combo2 does not clear. [Remember the model for combo2 is empty and therefore there shouldn't anything selected]</p>
  
  <p><strong>Qeustion: How do I clear the text in combo2 if the model is empty?</strong></p>
  
  <p>Here is a sample code:</p>
  
  <pre><code>public void select(final Entry entry) {
        if (entry == null)
           return;
  
           int index = entryList.indexOf(entry); // instance of SelectionInList from JGoodies
           boolean positive = index &gt;= 0 &amp;&amp; index &lt;= entryList.getSize() - 1;
  
           if (positive) {
  
                entryList.setSelection(entry);
  
  
                 subEntryList.setList(entryList.loadSubEntries(entry.getID()));
                 if (!subEntryList.isEmpty()) {
                      SubEntry e = subEntryList.getElementAt(0);
                      select(e);
                   }
          }
  </code></pre>
  
  <p>}</p>