Hello, I have the following problem, I'm trying to print a ticket, when printing in the LOG
it shows everything well but when I pass the string to a text field this format is lost, I'll leave an example
double total = 0;
f.format("%-15s %5s %10s\n", "Item", "Qty", "Price");
f.format("%-15s %5s %10s\n", "----", "---", "-----");
for (Detalle detalle: results) {
f.format("%-15.15s %5d %10.2f\n", detalle.getItem(), detalle.getCantidad(),(double) detalle.getValor());
total += detalle.getValor();
}
f.format("%-15s %5s %10.2f\n", "Tax", "", total * 0.06);
f.format("%-15s %5s %10s\n", "", "", "-----");
f.format("%-15s %5s %10.2f\n", "Total", "",
total * 1.06);
msg = f.toString();
System.out.print(f);
System.out.print(msg);
textImprimir.setText(f.toString());
The problem is that you use different fonts in the textfield and the LOG,
The font in the LOG uses the same space for every letter, the textfields ones doesn't
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.