whileループでjLabelを更新するにはどうすればよいですか? 私の理解では、javax.swing.timer を使用することですが、アクションも実行する必要があるため、よくわかりません。これは、while ループを通過するたびにカウンターを更新する必要がある while ループにあります。
これを行う簡単な方法はありますか?もしそうなら、jLabelの代わりに何を使用すればよいですか?
サンプルコードは、更新が必要なものの下にあります。
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)
{
}