I'm trying to print a barcode image, but when the program executes the .printDialog() I get the following warning on the console:
WARNING: gnome-keyring:: couldn't connect to: /tmp/keyring-y4THJ1/pkcs11: No such file or directory
And when I hit the print button, I get null.
Here is the code:
private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(new Printable()
{
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex != 0) {
return NO_SUCH_PAGE;
}
graphics.drawImage(imagen, 0, 0, imagen.getWidth(null), imagen.getHeight(null), null);
return PAGE_EXISTS;
}
});
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception prt) {
System.err.println(prt.getMessage());
}
}
}