title: Checking whether a JComboBox has the default value or not
body: <p>EDIT: Since the term "default value" is confusing, I changed it to "<strong>initial</strong> value."</p>
  
  <p>This is sort of an interesting question. I searched on the site for an answer, but didn't find one.</p>
  
  <p>I'm writing a validator class in Java, and one of the things I'd like to validate is whether or not a JComboBox has its initial value.</p>
  
  <p>Note, that I am <em>not</em> checking to see whether the user has selected a value; merely if the value that the user selected, is the same as the initial value.</p>
  
  <p>For example, let's say the options are:</p>
  
  <pre><code>Some Message Here
  Item 1
  Item 2
  Item 3
  </code></pre>
  
  <p>...etc. The "Some Message Here" text would be the initial value, and I would make it so using the setSelectedIndex or setSelectedItem methods.</p>
  
  <p>The problem is, once the user selects another item (say, Item 1), then there is no longer any way to tell what the initial value was supposed to be.</p>
  
  <p>I can't just check for a "magic number" (like, say, <code>if (cb.getSelectedIndex() == 0)</code> ) because the validator class has no way of knowing if the value at index 0 is, in fact, what the initial value is supposed to be. (And it may not be, for example in a list of U.S. states.)</p>
  
  <p>Nor can I use any of the event listeners. Think of a situation where the user selects "Item 1", then re-selects "Some Message Here". I would want this to fail validation.</p>
  
  <p>Any ideas?</p>