Как правильно закрыть мой jasperReport, когда он находится в Jdialog? - PullRequest
0 голосов
/ 19 января 2019

Я создаю Jdialog modallike this:

public class xxx extends javax.swing.JDialog {

public xxx(Object... parameters, boolean modal){
    super(parameters[0],modal);
    initComponents();
    //more code
}
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {                                         
    report();
} 

private void report(){
 String url = "C:\\ubication";

    CONEXIONBD cc = new CONEXIONBD();
    Connection cn = null;
    try {
        cn = cc.getConexion();
        JasperReport reporte = (JasperReport) JRLoader.loadObject(url);
        Map parametro = new HashMap();
        parametro.put("IDFACTURA", ptoVentas.ultimoID());
        parametro.put("TITULO", ptoVentas.leeNumFacturaParaDocReport(true));
        parametro.put("TIPODOC", ptoVentas.leeNumFacturaParaDocReport(false));

        JasperPrint jasperPrint = JasperFillManager.fillReport(reporte,parametro, cn);

        JasperViewer jviewer = new JasperViewer(jasperPrint, false);
        JasperPrintManager.printReport(jasperPrint, true);
        JDialog dialog = new JDialog(this);//the owner
        dialog.setContentPane(jviewer.getContentPane());
        dialog.setSize(jviewer.getSize());
        dialog.setTitle("Ticket");
        dialog.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent winevt) {
                dialog.dispose();
            }
        });            
        dialog.setVisible(true);

       }

Это создает отчет в JDialog, но когда я закрыл отчет и окно JDialog, в фоновом режиме все еще остается приложение, у кого-то есть какие-либо подсказки

...