File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Problem facing Printing the JFrame along with its content. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem facing Printing the JFrame along with its content." Watch "Problem facing Printing the JFrame along with its content." New topic
Author

Problem facing Printing the JFrame along with its content.

Angan Sen
Greenhorn

Joined: Jun 18, 2010
Posts: 10
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.


[Thumbnail for frame.PNG]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Oct 27, 2005
Posts: 19785
    
  20

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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Jun 18, 2010
Posts: 10
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.



[Thumbnail for photo.jpg]

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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

Joined: Jun 18, 2010
Posts: 10
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

Joined: May 03, 2008
Posts: 4664
    
    5

Jasper reports tutorials


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem facing Printing the JFrame along with its content.