title: Java frame not displaying properly during a while loop
body: <p>Here's a serious issue im having with a jFrame. I have one "Main Frame" where everything is done from, however i have another frame with a gif image in it (Loading, that circle that goes round and round), that is used as a splash screen saying "Processing, Please wait", however when i pull through that frame and my while loop runs, the frame goes blank and nothing displays until after the loop.</p>
  
  <p>I am assuming that this is due to the while loop consuming computer resources and "blocking" any other process from running.</p>
  
  <p>Please advise on what i should do.</p>
  
  <p>the code for declaring the new frame is standard but i will post it anyway below.</p>
  
  <pre><code>Processing nc = new Processing();
  nc.setVisible(true);
  </code></pre>
  
  <p>Here is my full code so you can see what im trying t achieve:</p>
  
  <p>Code from frame 1 (Excel Extractor):</p>
  
  <pre><code>Processing nc = new Processing();
      nc.setVisible(true);
  
      JFileChooser chooser = new JFileChooser();
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      int option = chooser.showOpenDialog(this); // parentComponent must a component like JFrame, JDialog...
      if (option == JFileChooser.APPROVE_OPTION) {
      File selectedFile = chooser.getSelectedFile();
       directory = selectedFile.getAbsolutePath();
       System.out.println(directory);
  
      }
  
  
     //create a input stream for your excel file from which data will be read. 
     DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
     SimpleDateFormat sdf = new SimpleDateFormat("HHmmss");
     String curdate = dateFormat.format(new Date());
     Calendar cal = Calendar.getInstance();
     cal.getTime();
     String curtime = sdf.format(cal.getTime());
  try{
  
  FileInputStream excelSheetInput = new FileInputStream(path);
  //POIFSFileSystem myFileSystem = new POIFSFileSystem(excelSheetInput);
      XSSFWorkbook myWorkBook = new XSSFWorkbook(excelSheetInput);
      //get first work sheet in your excel file.
      Sheet sheet = myWorkBook.getSheetAt(0);
      //we will read data in first rows(0) second column(1)
      Iterator&lt;Row&gt; rowIterator = sheet.iterator();
      Row myRow1 = sheet.getRow(0);
      Cell myCell1 = myRow1.getCell(0);
      String header="";
      Iterator&lt;Cell&gt; cellIterator1 = myRow1.cellIterator();
      int rowCount = 0;
  
      while(cellIterator1.hasNext()) {
  
                              Cell cell1 = cellIterator1.next();
  
                              switch(cell1.getCellType()) {
                                  case Cell.CELL_TYPE_BOOLEAN:
                                      header = header + "\""+cell1.getBooleanCellValue()+"\"" + ",";
                                      break;
                                  case Cell.CELL_TYPE_NUMERIC:
                                      cell1.setCellType(Cell.CELL_TYPE_STRING);
                                       header = header + "\""+cell1.getStringCellValue()+"\""+",";
                                      //System.out.print(cell.getStringCellValue() + "\t\t");
                                      break;
                                  case Cell.CELL_TYPE_STRING:
                                      header = header + "\""+cell1.getStringCellValue()+"\""+",";
                                      //System.out.print(cell.getStringCellValue() + "\t\t");
                                      break;
                              }
      }
  
      Row myRow = sheet.getRow(1);
      Cell myCell= myRow.getCell(0);
      Iterator&lt;Cell&gt; cellIterator;
      String firstCell = myCell.getStringCellValue();
      int count =1;
      String nextCell;
      String Matter = "Matter Number: "+firstCell;
      String num = firstCell;
      System.out.println(Matter);
      fWriter = new FileWriter(new File(directory, num+"_"+curdate+"_"+curtime+".csv"));
      writer = new BufferedWriter(fWriter);
      writer.write(Matter);
      writer.newLine();
      writer.write(header);
      writer.newLine();
      String temp;
      while(rowIterator.hasNext())
      {
  
  
          //temp = "" + rowCount;
          //jLabel5.setText(temp);
          myRow = sheet.getRow(count);
          cellIterator = myRow.cellIterator();
          Cell myCell2 = myRow.getCell(0);
          nextCell= myCell2.getStringCellValue();
  
  
          if(nextCell.equals(firstCell))
          {
  
              while(cellIterator.hasNext()) {
  
                              Cell cell = cellIterator.next();
  
                              switch(cell.getCellType()) {
                                  case Cell.CELL_TYPE_BOOLEAN:
                                      System.out.print(cell.getBooleanCellValue() + "\t\t");
                                      break;
                                  case Cell.CELL_TYPE_NUMERIC:
                                      cell.setCellType(Cell.CELL_TYPE_STRING);
  
                                       System.out.print(cell.getStringCellValue()+",");
  
                                      //System.out.print(cell.getStringCellValue() + "\t\t");
                                      writer.write(cell.getStringCellValue()+",");
                                      break;
                                  case Cell.CELL_TYPE_STRING:
                                      System.out.print(cell.getStringCellValue()+",");
                                      //System.out.print(cell.getStringCellValue() + "\t\t");
                                      writer.write(cell.getStringCellValue()+",");
                                      break;
                              }
                          }
              System.out.println();
              writer.newLine();
              count++;
              rowCount++;
  
  
  
          }
          else
          {          
  
              writer.close();
              myRow = sheet.getRow(count);
              myCell2= myRow.getCell(0);
              nextCell=myCell2.getStringCellValue();
              firstCell=nextCell;
              Matter = "Matter Number: "+firstCell;
              num = firstCell;
              System.out.println(Matter);
              fWriter = new FileWriter(new File(directory, num+"_"+curdate+"_"+curtime+".csv"));
              writer = new BufferedWriter(fWriter);
              writer.write(Matter);
              writer.newLine();
              writer.write(header);
              writer.newLine();
          }
  
  
      }
  }
  catch (Exception e)
  {
  }
  
    try {
      nc.dispose();
      writer.close();
  } catch (IOException ex) {
      Logger.getLogger(FileChooser.class.getName()).log(Level.SEVERE, null, ex);
  }
  }
  </code></pre>
  
  <p>The second frames code (Processing):</p>
  
  <pre><code>private void initComponents() {
  
      jLabel1 = new javax.swing.JLabel();
      jLabel2 = new javax.swing.JLabel();
  
      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
      jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
      jLabel1.setText("Processing, Please Wait...");
  
      jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/loading.gif"))); // NOI18N
  
      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(layout.createSequentialGroup()
              .addContainerGap()
              .addComponent(jLabel1)
              .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
          .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      );
      layout.setVerticalGroup(
          layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(layout.createSequentialGroup()
              .addContainerGap()
              .addComponent(jLabel1)
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              .addComponent(jLabel2)
              .addContainerGap())
      );
  
      pack();
  }
  </code></pre>