I tried to print a JPanel with this code:
try {
PrinterJob gap = PrinterJob.getPrinterJob();
gap.setPrintable(this);
boolean top = gap.printDialog();
if(top){
gap.print();
}
} catch (PrinterException ex) {
JOptionPane.showMessageDialog(null, " ERROR DEL PROGRAMA", "ERROR \n " + ex , JOptionPane.INFORMATION_MESSAGE);
}
but, it is appear the menu of configuration for select a printer. I do not want select a printer, I want that it is print from a printer for default or to select the printer in the code.