Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Problem facing Printing the JFrame along with its content.

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Sheriff
Posts: 22567
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22567
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for photo.jpg]
Sample Invoic structure
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jasper reports tutorials
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic