title: JComboBox showing blank items in Java
body: <p>I have 2x JComboBox:
  <code>showingsCb</code> and <code>timesCb</code></p>
  
  <p><code>showingsCb</code> contains a list of cinema showings that are pulled from my database.</p>
  
  <p><code>timesCb</code> contains a list of cinema showing times based on the selection from <code>showingsCb</code> which is also pulled from my database.</p>
  
  <p>Now I have managed to populate them both with correct data and the logic works fine, but here is my problem:</p>
  
  <p>I make a selection in <code>showingsCb</code> which then enables <code>timesCb</code> and upon clicking on <code>timesCb</code>, shows me a list of all the showing times based on the showing selected in <code>showingsCb</code>. This is working fine.</p>
  
  <p>I then select a different showing in <code>showingsCb</code> and upon clicking on <code>timesCb</code>, the list drops down and shows a blank list. The show times exist in this blank list but I can't see them (I know they're there because I can click on the blank spaces where they're supposed to be and it fills the <code>JComboBox</code> with my selection).</p>
  
  <p>I am using a <code>DefaultComboBoxModel</code> on the <code>JComboBox</code>, which is populated by an <code>ArrayList</code> or <code>Vector</code> (which retrieves results from my database using my own method). I am using an <code>ActionListener</code> on <code>showingsCb</code> to listen for the selection so it knows what showing times to return.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>        ArrayList&lt;String&gt; showingNames = Showing.getShowingList();
          showingNames.add(0, "--Select Showing--");
          DefaultComboBoxModel showingNameModel = new DefaultComboBoxModel(showingNames.toArray());
          showingsCb = new JComboBox(showingNameModel);
  
          Vector timesList = new Vector();
          timesList.add("--Select Time--");
          DefaultComboBoxModel timesModel = new DefaultComboBoxModel(timesList);
          timesCb = new JComboBox(timesModel);
          timesCb.setEnabled(false);
  
          showingsCb.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
  
                  timesList.clear();
                  timesList.add("--Select Time--");
                  timesCb.setSelectedIndex(0);
                  if (showingsCb.getSelectedIndex() == 0) {
                      timesCb.setEnabled(false);
                  } else {
                      timesCb.setEnabled(true);
                      ArrayList&lt;String&gt; times = Showing.getShowingTimes(Showing.getShowingIDByName(showingsCb.getSelectedItem().toString()));  //gather showing times based on showingID
                      Iterator itt = times.iterator();
                      while (itt.hasNext()) {
                          timesList.add(itt.next());
                      }
                  }
              }
  
          });
  </code></pre>
  
  <p>And here is a screenshot of how the results look when they're showing as blank:</p>
  
  <p><a href="https://i.stack.imgur.com/ZsXlK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZsXlK.png" alt="enter image description here"></a></p>
  
  <p>If I were to click anywhere on that blank dropdown list then the selection I've chosen will appear as my selected item.</p>
  
  <p>I'm also having trouble obsoleting the Vector from my code on the <code>timesCb</code> <code>JComboBox</code></p>