Code:
final JFrame f = new JFrame("Pulververwaltung");
f.getContentPane().add(jScrollPane6, BorderLayout.CENTER);
try {
PrinterJob pjob = PrinterJob.getPrinterJob();
pjob.setJobName("Pulververwaltung");
pjob.setCopies(1);
// Tell the print system how to print our pages.
pjob.setPrintable(new Printable() {
/** called from the printer system to print each page */
public int print(Graphics pg, PageFormat pf, int pageNum) {
if (pageNum>0) // we only print one page
return Printable.NO_SUCH_PAGE; // ie., end of job
// Now (drum roll please), ask "thing" to paint itself
// on the printer, by calling its paint() method with
// a Printjob Graphics instead of a Window Graphics.
table.paint(pg);
// Tell print system that the page is ready to print
return Printable.PAGE_EXISTS;
}
});
if (pjob.printDialog() == false) // choose printer
return; // user cancelled
pjob.print(); // Finally, do the printing.
}
catch (PrinterException pe) {
JOptionPane.showMessageDialog(f,
"Printer error" + pe, "Printing error",
JOptionPane.ERROR_MESSAGE);
}
Ich kann einfach keine Swing Elemente drucken wenn ich das hier ausführe wird eine leere Seite gedruckt????