title: Why does JScrollPane with JList disappear when the JList becomes empty after last remove element?
body: <p>I have a JPanel using a BorderLayout Jlists EAST, WEST, CENTER, and SOUTH. When I remove all the elements (now making it empty) from the SOUTH JList and the UI repaints ... either from manually call to repaint(), changing focus to another window then coming back, or min/max'ing the window, etc ... the JList just disappears from view.</p>
  
  <p>As a result, I am unable to drag and drop elements from the other showing JLists into the SOUTH JList because it is not showing ... very annoying.</p>
  
  <p>How do I get around this?</p>
  
  <p>Code:</p>
  
  <h2>Main.java</h2>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.EventQueue;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  
  public class Main {
      public static void main(String[] args) {
          new Main();
      }
  
      private ExampleList westItems;          
      private ExampleList eastItems;
      private ExampleList southItems;         
      private ExampleList centerItems;
  
      public Main(){
          EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {                     
                  JFrame frame = new JFrame();
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
                  JPanel contentPane = new JPanel(new BorderLayout());
                  JPanel mainPane = new JPanel(new BorderLayout());
                  frame.setContentPane(contentPane);
  
                  westItems = new ExampleList();              
                  eastItems = new ExampleList();
                  southItems = new ExampleList();         
                  centerItems = new ExampleList();
  
                  mainPane.add(westItems, BorderLayout.WEST);
                  mainPane.add(eastItems, BorderLayout.EAST);
                  mainPane.add(southItems, BorderLayout.SOUTH);
                  mainPane.add(centerItems, BorderLayout.CENTER);
  
                  JButton addButton = new JButton("Add Items");
                  addButton.addActionListener(new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent evt) {
                          for(int i = 0; i &lt; 5; i++){
                              westItems.addItem(new String("West "+i));
                              eastItems.addItem(new String("East "+i));
                              southItems.addItem(new String("South "+i));
                              centerItems.addItem(new String("Center "+i));
                          }
                      }
                  });
  
                  JButton removeFromSouthButton = new JButton("Remove South Item");
                  removeFromSouthButton.addActionListener(new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent evt) {
                          // Remove the last element
                          int count = southItems.getModel().getSize();
                          if( count &gt; 0 )
                              southItems.removeItemAt(0);
                      }
                  });             
  
                  JPanel buttonsPanel = new JPanel();
                  buttonsPanel.add(addButton);
                  buttonsPanel.add(removeFromSouthButton);
  
                  contentPane.add(mainPane, BorderLayout.CENTER);
                  contentPane.add(buttonsPanel, BorderLayout.SOUTH);
  
                  frame.setExtendedState(frame.getExtendedState()|JFrame.MAXIMIZED_BOTH);
                  frame.setVisible(true);
                  frame.repaint();                
              }
          });
  
      }
  }
  </code></pre>
  
  <h2>ExampleList.java</h2>
  
  <pre><code>import javax.swing.BorderFactory;
  import javax.swing.DefaultListModel;
  import javax.swing.JList;
  import javax.swing.ListSelectionModel;
  
  @SuppressWarnings("rawtypes")
  public class ExampleList extends JList {
      private static final long serialVersionUID = 1L;
      private DefaultListModel&lt;String&gt; model;
  
      @SuppressWarnings("unchecked")
      public ExampleList() {
  
          model = new DefaultListModel&lt;String&gt;();
          setModel(model);
          setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          setVisibleRowCount(1);        
  
          setBorder(BorderFactory.createTitledBorder("Example List"));
  
          setFixedCellWidth(150);
          setFixedCellHeight(150);
      }
  
      public void removeAllElements(){
          model.removeAllElements();
      }
  
      public void removeItem(String item) {
          model.removeElement(item);
  
      }
  
      public void removeItemAt(int index) {
          model.remove(index);
  
      }
  
      public void addItem(String item) {
          model.addElement(item);
  
      }
  
  // End Mouse Listener Stuff
  }
  </code></pre>