drawImage metode virker ikke??
Hvorfor virker denne kode ikke, ifølge compileren er problemet g.drawImage metoden??:import java.awt.*;
import java.awt.print.*;
import java.awt.image.*;
import java.awt.Graphics.*;
class PrinTesten {
private Image image;
public PrinTesten() {
PrinterJob job = PrinterJob.getPrinterJob();
Book bk = new Book();
Printable printAble = new Printable() {
public int print(Graphics g, PageFormat page, int index) {
page.setOrientation(PageFormat.LANDSCAPE);
g.setClip((int)page.getImageableX(), (int)page.getImageableY(),
(int)page.getWidth(), (int) page.getHeight());
g.drawImage(image, 0, 0, this);
g.drawString("This text is at the picture", image.getHeight() + 20, 100);
return 0;
}
};
bk.append(printAble, job.defaultPage());
job.setPageable(bk);
if (job.printDialog()) {
try {
job.print();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}