这个问题已经在这里有一个答案:
- 如何防止父框架关闭时关闭子框架(Java + iReport的)? 1个回答
当JasperViewer
出现和我关闭它,主框架/父母也被关闭。 如何避免这种情况?
这是我的代码..
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);
}