• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in printing swing components?

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a registration page, and after registration of a student i need to print the tc (transfer certificate), in the (Photo1430.jpg) image format, (in the same format shown in the image).
field values are coming from the database.(ie. value of name, value of dob, value of place so on...)

i am doing something like this:



this code giving me output like this the below image(output.png):
i am just trying to achieve, what i want(like in my first image(Photo1430.jpg)), so what i have not added all the component to my code (just testing).

Ouestions:-
it will print from the top left corner of page(leaving the default printer margin), what i need to do to give a header space (say, 2 inch or 144 points)??
m i doing this right way to achieve my desired output??
also how do i add values of my fields over the dots??

output.PNG image is what i am doing and Photo1430.jpg is what i want.
Thank you..
Photo1430.jpg
[Thumbnail for Photo1430.jpg]
output.PNG
[Thumbnail for output.PNG]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> i am doing something like this:

that's what's annoying, why don't you post the actual code, not 'something like'

look at the posted code, at the top of PrintUIWindow()
JFrame frameToPrint;

then in main()
JFrame f = new JFrame("Print TC");
which is the frame on the screen, the one with the print button

then the print code
frameToPrint.printAll(g);

so how can you possibly print anything out?

anyway, the clue to what you want is in the name 'frameToPrint'
i.e. if you don't want the frame printed, what do you think might go there instead?

also, you might want to change this line (not part of the problem, but think about it)
panel.add("South", printButton);
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but michael i can't check it, because i have no pritner attached to my laptop.
and my question is how i will get the layout something like which is in Photo1430.jpg.
i mean the dotted lines and the field values over them??
also how i will get like in that image at point number 3,(multiple lines), and also at point number 8 (the rectangle type table) with dynamic values.?
and my main frame has border layout, and has menu at the top, which has print menuItem, and by clicking on that i am changin the BorderLayout.CENTER to my PrintReport class.

PrintReport.java


Above is the class which i am attaching to my main frame/class.
i am not able to get layout like that image.
can i print panel, i am printing panel here but not working.??

Thank you..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> my question is how i will get the layout something like which is in Photo1430.jpg

a JTextPane might be your best bet - you should be able to format it, add tables etc,
so that it looks like the photo image, then print out the textPane
 
Greenhorn
Posts: 22
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there !!!
You need to print your GUI ???

Or maybe you should to try with a Report maker, like Ireport.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii michael


a JTextPane might be your best bet - you should be able to format it, add tables etc,
so that it looks like the photo image, then print out the textPane.



yes it makes my work, i use jeditorpane.
i found one interesting for this on the internet, and make some changes into that.
i m posting the working code, how i did.
below is the working code, if anyone wants.

TestPreview.java


PrintPreview.java


working code with print preview, i am just taking the values from the database.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii tobian


You need to print your GUI ???


yes..


Or maybe you should to try with a Report maker, like Ireport.



yes i thought to use them, but the problem i m getting is to create installer for the software.
if i use ireport i need to attach the jar also, when i create the installer, and i am facing difficulties in attaching the jars.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic