How do i update a jLabel in a while loop? My understanding is to use a javax.swing.timer however i dont quite understand it because i need an action performed as well, now this is in a while loop that needs to update a counter to every time it passes through the while loop.
Is there an easier way to do this and if so what should i use instead of a jLabel?
Sample code is below of what i need to update.
int rowCount = 0;
while(rowIterator.hasNext())
{
jLabel5.setText(""+ rowCount); //<-- i need this to update
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)
{
}