Do not know if this is the right place to post it. But I have non game related issue:
Is there a way to associate printDialog with a frame ? It appears that when I drag the print dialog across the screen, the screen gets repainted by the print dialog
and the application focus is lost.
public class ex5 extends JComponent implements Printable, MouseMotionListener,ActionListener,MouseListener
{
…
protected JFrame frame;
public ex5(JFrame frame)
{
this.frame=frame;
}
…
public void printImage()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog())
{
try {
printJob.print();
} catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}
I know that PrintJob class allow you to issue getPrintJob with specified frame such as:
PrintJob printJob = Toolkit.getDefaultToolkit().getPrintJob(frame, “Hello World”, printprefs);
But how can I specify a frame for printDialog ? The printing samples in Java tutorial have
the same issue. The samples can be found at http://java.sun.com/docs/books/tutorial/2d/printing/overview.html
If you drag the printDialog, the screen will get painted by the printDialog.
Thanks
Jay