• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bill printing issue using java swing with exact string format  RSS feed

 
Sagar Deshmukh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one java program for printing shop bill.
As far as i have written below code to print



I want exact same output as given reference image

But i am getting some weird output as like below

==========================
No. ItemName Rate Qty(gm) Amount
==========================
BadamType 1
Kaju 19
Differentname 3
==========================

Kindly help, i have Google, put 2 days to solve but didn't find any solution.

Regards,
Sagar
20100918_0016-Greenwood-Seafood-Restaurant_bill-102.50-for-5-people.jpg
[Thumbnail for 20100918_0016-Greenwood-Seafood-Restaurant_bill-102.50-for-5-people.jpg]
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have arrived in the wrong forum; this is for discussion of the ranch; I shall try to move you.

Why are you using StringBuffer rather than StringBuilder? Actually I think you might be better off using String#format to create the output. Then you can have right‑justified and left‑justified Strings occupying a certain width.
There is something peculiar about your having an array of 500 StringBuffer objects. Why are you doing that? There is something even more peculiar about using y+=15 as an expression.
 
Sagar Deshmukh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you so much for your reply.

May i know which is correct forum for this question i am confused.

As you said, i need to use String Builder, i tried that but still getting same weird output. Interesting part is , when i print it using sop it gives a correct format with proper logic, don't know why not on printer
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!