title: I'm trying to remove items from a jList
body: <p>I am very new to Java, having used Visual Basic for some years. I have created a basic GUI using NetBeans. It contains a jList, called lstMain. I have created a DefaultListModel called LISTMODEL, and I can add String items to the jList. When I try to remove items using</p>
  
  <pre><code>int M = lstMain.getSelectedIndex();
  LISTMODEL.remove(M);
  </code></pre>
  
  <p>odd things happen. Sometimes the list item is removed, leaving one item fewer. This is what I'd expect. Sometimes the list items appear to remain in place, unchanged, but the last item is inaccessible. If I click on an accessible item it changes to what I’d have expected - ie what was the next item. Sometimes the items do change, but the last one is still inaccessible. This all seems a far cry from the ease of use of a Visual Basic listbox. Can anyone tell me what is going on?</p>