• 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

Printing Solved but?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,
I solved my printing multiple pages issue but now I have another problem. To be able to print, i create an instance of my Display class, below, and append it to my book (casting it to Printable first).
Now since the end user might be printin lots of pages i do not want to make my JFrame visible. I want it to be printed in the background. However if i do a setVisible(false) on my JFrame, my pages still print but they come out BLANK. I figure its because i'm doing a "paint" in my print routine. How can i print my pages in the background without making my frames visible. Thankx.
public class Display
extends JFrame implements java.awt.print.Printable{
JPanel c = new JPanel();
public void makeComponents(JPanel c){//makes display components
}
Display(String title){
super(title);
makeComponents(c);
this.getContentPane().add(c);
this.setSize(672,792);
this.setVisible(true);
//i want => this.setVisible(false);
}
public int print(Graphics g, java.awt.print.PageFormat pf, int pi) throws java.awt.print.PrinterException {
Graphics2D g2 = (Graphics2D) g;
g2.translate(pf.getImageableX(), pf.getImageableY());
paint (g2);
return java.awt.print.Printable.PAGE_EXISTS;
}
}
[This message has been edited by Charlie Boss (edited June 19, 2001).]
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Charlie,
Until java includes headless graphics into toolKit you must make any component visible to be able to print it out.
I just set the frame location to 3000,3000 so that it doesn't show on the display (except for the task bar).
Good Luck,
Manfred.
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic