If WindowClosing is used to run an event on a jframe when closing it, How could you run an event with jasperviewer when you close your window? The reason for this is to ask the user if he wants to generate a pdf of the jasper or just close it.
Here my code:
PS: I tried to run an if but it does not work because it runs once, I know.
int codigo = Integer . parseInt(dia + "" + mes + "" + año + "" + valor);
//
JasperViewer jasperViewer = new JasperViewer(jprint, false);//false evita que se cierre toda la aplicacion
jasperViewer . setTitle("Cotizacion ");
jasperViewer . setVisible(true);
//
if (jasperViewer != null && jasperViewer . isVisible()) {
} else {
int dialogbutton = JOptionPane . showConfirmDialog(
null,
"Desea Guardar el reporte en pdf",
"Alerta",
JOptionPane . YES_NO_OPTION
);
if (dialogbutton == 0) {
JasperExportManager . exportReportToPdfFile(
jprint,
"C:\Users\HENRY\Documents\Cotizacion" + Fecha + valor + ".pdf"
);
File go = new File("C:\Users\HENRY\Documents\Cotizacion" + Fecha + valor + ".pdf");
Desktop . getDesktop() . open(go);
}}