title: Result Set not always being shown in the JTable
body: <p>I am creating an application in Java which retrieves some information from a MySQL database and then displays it in a JTable on the screen.</p>
  
  <p>The code I am using to get and put the information into a DefaultListModel&lt;> is shown below. The DefaultListModel&lt;> is then fed to the JTable which displays the information onto the screen.</p>
  
  <pre><code>SwingWorker&lt;Void, Void&gt; worker = new SwingWorker&lt; Void, Void&gt;() {
  
          @Override
          public Void doInBackground() {
  
              String SQL = "SELECT * FROM AddABill";
  
              try {
                  Statement stmt = GlobalVars.conn.createStatement();
  
                  ResultSet rs = stmt.executeQuery(SQL);
  
                  menuOptions.clear();
  
                  while(rs.next()){
  
                      menuOptions.addElement(rs.getString(1) + " - " + rs.getString(2));
                  }
  
                  rs.close();
                  stmt.close();
              }
  
              catch (SQLException e) {
                  System.out.println("An Error Was Detected! :/");
              }
  
              return null;
          }
  
          @Override
          public void done(){
              loadingGif.setVisible(false);
          }
  
      };
  
      worker.execute();
  </code></pre>
  
  <p>The issue I am having is that sometimes the information is displayed onto the screen and sometimes it isn't. Since there is no change in the query used I am assuming it is something to do with the MySQL connection.</p>
  
  <p>The JTable and MenuOptions are setup like this</p>
  
  <pre><code>menuOptions = new DefaultListModel&lt;&gt;();
  menuOptions.addElement("");
  
  menuList = new JList&lt;&gt;(menuOptions);
  menuList.setFont(new Font("Myriad Hebrew", Font.PLAIN, 32));
  menuList.setBackground(Color.decode("#005952"));
  menuList.setForeground(Color.decode("#BEC423"));
  menuList.setSelectionBackground(Color.decode("#660033"));
  menuList.setSelectionForeground(Color.decode("#FFFFFF"));
  </code></pre>
  
  <p>So the question I am wondering is how can I make sure that the information is always displayed on the screen. A picture of when it is displayed and not displayed is shown below.</p>
  
  <p>Displayed:</p>
  
  <p><a href="https://i.stack.imgur.com/62ZBt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/62ZBt.png" alt="Displayed"></a></p>
  
  <p>Not Displayed:</p>
  
  <p><a href="https://i.stack.imgur.com/j6ba1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j6ba1.png" alt="Not Displayed"></a></p>
  
  <p>On a final note to get the information to show I have to keep on re-running the code until it is eventually shown.</p>
  
  <p>Any help is much appreciated.</p>