Java print frame content

257 Views Asked by At

I have the following code

private static Properties printProperties = new Properties();

public void print() {
        PrintJob printJob = null;
        try {
            printJob = getToolkit().getPrintJob(this, "Draw app", printProperties);
        } catch (Exception e) {
        System.out.println(e.getMessage());
        }
        if (printJob == null)
            return;

And when I'm clicking on the printing button in my menu I get a NullpointerException, which by the PrintJob class API is invoked by a null frame problem , If Someone can explain how to solve this problem. Thanks for helping.

0

There are 0 best solutions below