title: Why does this integer return 0 although it's not 0?
body: <p>I'm creating a software that's supposed to execute a console command. The command varies on your configuration you set up in the actual application.</p>
  
  <p>The problem is, one of the commands (4 in total) needs to catch an integer in order to work for the configuration.</p>
  
  <p>The integer is set by a dropdown list via this code:</p>
  
  <pre><code>private String[] osList = {"Choose OS", "Windows 7 Pro", "Windows 7 Home Basic", "Windows 7 Home Premium", "Windows 7 Ultimate"};
  private JComboBox osDropDown = new JComboBox(osList);
  public int osIndex;
  
  osDropDown.addItemListener(new ItemListener() {
              public void itemStateChanged(ItemEvent e) {
                  if(e.getStateChange() == ItemEvent.SELECTED) {
                      Object item = e.getItem();
  
                      if(item.equals(osList[1])) {
                          osIndex = 3;
                      } else if(item.equals(osList[2])) {
                          osIndex = 1;
                      } else if(item.equals(osList[3])) {
                          osIndex = 2;
                      } else if(item.equals(osList[4])) {
                          osIndex = 4;
                      }
                  }
              }
          });
  </code></pre>
  
  <p>As you can see, the variable osIndex is supposed to be set to 3 for example if you chose "Windows 7 pro".<br>
  This is the command that's executed:</p>
  
  <pre><code>"dism /mount-wim /wimfile:install.wim /index:" + formPanel.osIndex + " /mountdir:mount"
  </code></pre>
  
  <p>But for some weird reason, it returns 0 on osIndex no matter which item in the list I choose.. And I have no idea why?</p>
  
  <p>If I use this code, it outputs the correct value of osIndex when I choose that on the list. But when I try to run the command after choosing, it still returns 0.</p>
  
  <pre><code>if(item.equals(osList[1])) {
      osIndex = 3;
      System.out.println(osList[1] + " [" + osIndex + "]");
  } else if(item.equals(osList[2])) {
      osIndex = 1;
      System.out.println(osList[2] + " [" + osIndex + "]");
  } else if(item.equals(osList[3])) {
      osIndex = 2;
      System.out.println(osList[3] + " [" + osIndex + "]");
  } else if(item.equals(osList[4])) {
      osIndex = 4;
      System.out.println(osList[4] + " [" + osIndex + "]");
  }
  </code></pre>
  
  <p>EDIT: It seems that the command in the array is set and not changed once I change the item in the list. I need to, somehow, make it so when I change the list item; that's the point where the command in the array is assigned to the variable. Any good ideas on how to do this?</p>
  
  <p>EDIT 2: Solved it by doing this; once I click the "Go" button, it sets the commands text in the array to:</p>
  
  <pre><code>cmdExec.cmd[3] = "dism /mount-wim /wimfile:install.wim /index:" + formPanel.getOsIndex() + " /mountdir:mount";
  </code></pre>
  
  <p>There's no way that this is the best solution, but it was pretty much the only one I could currently figure out. If there's anyone with any better idea, please let me know!</p>