0

我像这样创建了一个 Jdialog 模态:

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 窗口时,在后台仍然运行应用程序,有人有任何线索吗?

4

0 回答 0