Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem facing Printing the JFrame along with its content.

 
Angan Sen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to print the JPanel on a JFrame on along with one table . Below is the snapshot of that Frame.

Please help me out... please provide the steps. The contents are available on the web is not sufficient for printing components like JTable. I am a newbie so please provide help considering my level of experience and knowledge. I don even need ready made code... just a proper working lead.
frame.PNG
[Thumbnail for frame.PNG]
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently you haven't checked the JTable Javadoc page or you would have seen the print methods that allow you to do just that - print a JTable.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> print a JTable.

Not sure I'm reading it correctly, but it seems the OP wants to print the active window
i.e table/panel/frame as one, not just the table

there's plenty of code around to save the table/panel/frame as an image,
might be easy enough to print it instead, don't know, not tried it.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.awt.print.Printable's print method provides a Graphics object that can be used in java.awt.Component's print method. The only thing that then needs to be done is printing multiple pages.

I still think that JTable's print method, in combination with a MessageFormat for the header, should be enough.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I still think that JTable's print method, in combination with a MessageFormat for the header, should be enough.

Interesting, thanks, I must try it (never had a need for it, but would be nice to get it to work)
 
Angan Sen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response, I have tried with jtable's print method. I t works fine for printing Jtable only. But I have to print a invoice formatted on a JPanel, so there will be other lots of other JtextComponents, along with Table and images.just like the attached image.

I have planned to preview the format in a Jframe on a JPanel then on button click of that Frame the Jpanel will be sent to the printer.
please help me with this.I have a deadline to meet. Any help will be gladly appreciated.
photo.jpg
Sample Invoic structure
[Thumbnail for photo.jpg]
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if you would you be better off using a dedicated reporting tool for this portion of your program such as JasperReports. caveat: I'm no expert in this area. Luck!
 
Angan Sen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:I wonder if you would you be better off using a dedicated reporting tool for this portion of your program such as JasperReports. caveat: I'm no expert in this area. Luck!


I have downloaded Jasper reporting tool. Can you provide some information about using this tool for printing JPanel.Please at least some dedicated tutorial for that purpose.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jasper reports tutorials
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic