2011-08-15 11 views
0

フレームを印刷できるコードはすでに書かれていますが、今はprintJobを使用したいのは、 。 BufferedImageをPrintableに変換してコードにprintjobを使用する方法はありますか? THXBufferedImageをPrintableに変換してprintJobを使用する方法

if(command.equals("Print")){ 
     //saves image as temp and then prints it 

    File out = new File("temp.jpg"); 
    BufferedImage myImage = new BufferedImage((int) frame.getWidth(), 
         (int) frame.getHeight(), 
         BufferedImage.TYPE_INT_RGB); 

    frame.paintAll(myImage.createGraphics()); 
    try{ 
     ImageIO.write(myImage, "jpg", out); 
     PrintImage.printImage("temp.jpg"); 
    }catch (IOException exception){ 
     exception.printStackTrace(); 
    } catch (Exception e2) { 
     e2.printStackTrace(); 
    } 
} 

答えて

4

あなたはその後、PrinterJobprint方法にそれを渡し、フレームの基礎となるGraphicsオブジェクトを取得するにはgetGraphicsを使用することができます。

関連する問題