关闭JasperViewer时如何防止关闭JFrame

时间:2013-08-05 23:10:21

标签: java jasper-reports

关闭 JasperViewer 时如何防止关闭 JFrame

try {
          JasperDesign jd = JRXmlLoader.load("D:\\Projects\\DiagonosisCentre\\reports\\reportAddNewPatient.jrxml");
          String sqlr = "SELECT * FROM current where patientID = '"+id+"'";
          JRDesignQuery newQuery = new JRDesignQuery();
          newQuery.setText(sqlr);
          jd.setQuery(newQuery);
          JasperReport jr = JasperCompileManager.compileReport(jd);
          JasperPrint jp = JasperFillManager.fillReport(jr, null, db.conn);
          JasperViewer.viewReport(jp);
     } catch (JRException jRException) {
          JOptionPane.showMessageDialog(null, "catch 1"+jRException);
     }

1 个答案:

答案 0 :(得分:2)

而不是:

JasperViewer.viewReport(jp);

添加:

JasperViewer.viewReport(jp, false);