Double ans;
Double cas = Double.parseDouble(cash.getText().trim());
Double total = Double.parseDouble(totlw.getText().trim());
ans = cas - total;
chg.setText(String.valueOf(ans));
// fs.printfrm.append("\t TOTAL COST =GH¢ "+
totlw.getText().toString());
}
try (BufferedWriter bw = new BufferedWriter(new FileWriter("file.txt")))
{
bw.write("First line");
bw.newLine();
bw.write("Second line");
bw.newLine();
bw.write("The last line.");
bw.newLine();
bw.flush();
}
catch (Exception e)
{
System.err.println("Unable to write to the file."); // Or any other error message handling
}
Don't forget to add imports, NetBeans will add them for you if you click on
the light-bulb icon
HI,
Doubt if it's still of interest, but the problem is that TablePrintable is
single-use. There's no way to reset it for a second pass.
Calling jTable.getPrintable() a second time gets a fresh TablePrintable, so
you need to use the first for counting pages, and the second for actual
printing. JAVA Training "JAVA Training ":https://www.sevenmentor.com/…-in-pune.php
Actually, you don't actually need to count the pages. getNumberofPages() can
return zero; just end the print loop for when it runs out of pages.
An alternative workaround would be to copy the source of TablePrintable and
add a reset method for variable 'last' and the Rectangle values.