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).]