2013-08-05 159 views
2

如何防止在關閉時關閉JFrameJasperViewer如何在關閉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); 
    } 

回答

2

取而代之的是:

JasperViewer.viewReport(jp); 

補充一點:

JasperViewer.viewReport(jp, false);