本文介绍了当JasperViewer出现并关闭它时,主框架/父框架也关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

当出现 JasperViewer 并关闭它时,主框架/父框架也关闭。如何防止这种情况?

When a JasperViewer appear and I close it, the main frame / parent also closed. How to prevent this?

这是我的代码..

 private void cmdprintidMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        try {
            JasperDesign jasperDesign = JRXmlLoader.load("report12.jrxml");
            String sql = "select * from db1 where Company LIKE '" + txtcompany.getText() + "%'";
            JRDesignQuery newQuery = new JRDesignQuery();
            newQuery.setText(sql);
            jasperDesign.setQuery(newQuery);
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
            JasperViewer.viewReport(jasperPrint);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }


推荐答案

更改此:
JasperViewer.viewReport(jasperPrint);

JasperViewer.viewReport(jasperPrint,false );
这将正常工作。

to JasperViewer.viewReport(jasperPrint, false);This will work properly.

这篇关于当JasperViewer出现并关闭它时,主框架/父框架也关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 08:42