I am new to Java and I am trying to add print-preview in my J-frame, I tried a PrintPreview class found on given below link. But problem with this class is after creating an object to PrintPreview class it is asking for (Frame, canvas, page). In frame I pass this for my current frame, and in page "A4" but for convas I didn't getting what to pass in constructor of PrintPreview.
I opened convas2D class for which convas is referring but can't find any help?
If you'd like a better help, try submitting your code but see if that piece of code help you:
class MyCanvas extends Canvas {
public MyCanvas () {
setBackground (Color.GRAY);
setSize(300, 300);
}
public void paint (Graphics g) {
Graphics2D g2;
g2 = (Graphics2D) g;
g2.drawString ("It is a custom canvas area", 70, 70);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.